JamesWilcox Posted February 8, 2007 Share Posted February 8, 2007 How do you open a file read its contents and pass the contents to a control? Say in the file you had: description, frequency, multiplier For example: signal, 110, 3.0 And you want to send it to a control that has three fields: description, frequency, multiplier You decide to open a file and read the contents and send the contents to the control to fill in these three fields. How do you do that? Please help... Link to comment Share on other sites More sharing options...
lod3n Posted February 8, 2007 Share Posted February 8, 2007 FileRead, StringSplit, and GuiCtrlSetData [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
Shevilie Posted February 8, 2007 Share Posted February 8, 2007 Start in the Help file.. Look for FileOpen FileReadLine ControlSetText Or have a try in the Autoit1-2-3 in my signature Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
JamesWilcox Posted February 8, 2007 Author Share Posted February 8, 2007 I did this: ; Script Start - Add your code below here $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop ControlSetText ( "title", "text", controlID, "new text" [, flag] ); what do I put here to put data read from file into the control? MsgBox(0, "Line read:", $line) Wend FileClose($file) Link to comment Share on other sites More sharing options...
JamesWilcox Posted February 8, 2007 Author Share Posted February 8, 2007 I did this: ; Script Start - Add your code below here $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop ControlSetText ( "title", "text", controlID, "new text" [, flag] ); what do I put here to put data read from file into the control? MsgBox(0, "Line read:", $line) Wend FileClose($file) Link to comment Share on other sites More sharing options...
MHz Posted February 9, 2007 Share Posted February 9, 2007 (edited) Try this. I added ControlSend() in for you since you are doing line by line and added 2nd ControlSend() without raw mode for @CRLF. ; Script Start - Add your code below here $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop ControlSend('title', 'text', 'ControlID', $line, 1) ControlSend('title', 'text', 'ControlID', @CRLF) MsgBox(0, "Line read:", $line) Wend FileClose($file) Edited February 9, 2007 by MHz Link to comment Share on other sites More sharing options...
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