killaz219 Posted November 18, 2004 Posted November 18, 2004 (edited) How would you make a script that reads the text from a file and updates a gui input? I would also like to know how to make the input box so when text hits the border, it goes down one line instead of continuing. Help would be appreciated. Thanks, Aaron Edited November 18, 2004 by killaz219
Guest Py7|-|[]/\/ Posted November 18, 2004 Posted November 18, 2004 FileWriteLine FileReadLine Assign FileReadLine to a variable then print the variable in the GUI.
killaz219 Posted November 18, 2004 Author Posted November 18, 2004 FileWriteLineFileReadLineAssign FileReadLine to a variable then print the variable in the GUI.<{POST_SNAPBACK}>I've tried that, but I want a more experienced person (like this-is-me, valik, etc.) to give me a sample code, or better support.
this-is-me Posted November 18, 2004 Posted November 18, 2004 $filename = "C:\boot.ini" $txt = FileRead($filename, FileGetSize($filename)) GUICtrlSetData($ctrlid, $txt) Who else would I be?
killaz219 Posted November 18, 2004 Author Posted November 18, 2004 (edited) $filename = "C:\boot.ini" $txt = FileRead($filename, FileGetSize($filename)) GUICtrlSetData($ctrlid, $txt)<{POST_SNAPBACK}>That didnt work.. Let me give you a little something to work with GUICreate("my gui", 449, 338, (@DesktopWidth - 449) / 2, (@DesktopHeight - 338) / 2, 0x04CF0000) $Input_14 = GUICtrlCreateInput("Enter text here", 250, 20, 180, 160, 0x00200000) $Button_17 = GUICtrlCreateButton("Text from File", 250, 290, 180, 40) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = -3 ExitLoop Case $msg = $button_17 $file = FileOpenDialog ("Open what file?", @desktopdir, "Text files (*.txt)") $file2 = $file $file = FileOpen ($file2, 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf While 1 $chars = FileRead($file, FileGetSize($file)) If @error = -1 Then ExitLoop GUICtrlSetData ($input_14, $chars) Wend FileClose($file) EndSelect WEnd Edited November 18, 2004 by killaz219
this-is-me Posted November 18, 2004 Posted November 18, 2004 (edited) ( a ) You don't need to open the file since just calling fileread with the filename will open and close the file in the function call ( b ) You don't need to while or wend at all. You can say if NOT @error then ... EDIT: try this: GUICreate("my gui", 449, 338, (@DesktopWidth - 449) / 2, (@DesktopHeight - 338) / 2, 0x04CF0000) $Input_14 = GUICtrlCreateEdit("Enter text here", 250, 20, 180, 160, 0x00200000) $Button_17 = GUICtrlCreateButton("Text from File", 250, 290, 180, 40) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = -3 ExitLoop Case $msg = $button_17 $file = FileOpenDialog ("Open what file?", @desktopdir, "Text files (*.txt)") if not @error then $chars = FileRead($file, FileGetSize($file)) GUICtrlSetData ($input_14, $chars) endif EndSelect WEnd Edited November 18, 2004 by this-is-me Who else would I be?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now