Jump to content

Read File question


 Share

Recommended Posts

Hi everyone!

I can't understand how to read whole txt file & set it data into Editbox.

Tnks

Check this proof-of-concept script:

#include <GuiConstants.au3>

GuiCreate("MyGUI", 361, 261,-1, -1 )

$Edit_1 = GuiCtrlCreateEdit("My default text.", 10, 10, 340, 190)
$Button_2 = GuiCtrlCreateButton("File 2 EDIT", 20, 220, 90, 30)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
        ExitLoop
    Case $Button_2
        _file2Edit()

    EndSwitch
WEnd
Exit


Func _file2Edit()
    $file = FileOpen(@ScriptFullPath, 0)
    If $file = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf
    $sContent = FileRead($file)
    GUICtrlSetData($Edit_1, $sContent)
    
    FileClose($file)
EndFunc

Read the examples in the helpfile.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...