davykiash Posted May 19, 2006 Share Posted May 19, 2006 hi ive got a text file having the following format: Bob 45 Nairobi David 80 Kisumu Kate 34 Eldoret Alice 90 Kiambu How do i loop through this lines of text while taking each value of text eg 'Bob' '45' and 'Nairobi' and writing it to 3 controls on a form? let the contol names be Edit1,Edit2 and Edit3 my exe will clear the edit boxes after send("!S") before the loop proceeds to the next line. Link to comment Share on other sites More sharing options...
Valuater Posted May 19, 2006 Share Posted May 19, 2006 (edited) 1 Welcome to the forums 2 you try we help - thats the policy ( you dont post-an-order to pick-up later 3 try looking into arrays and "stringsplit 8) EDIT A filereadtoarray b stringsplit c guictrlcreateedit d for/next loop e guictrlsetdata Edited May 19, 2006 by Valuater Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 19, 2006 Moderators Share Posted May 19, 2006 2you try we help - thats the policy ( you dont post-an-order to pick-up later That so reminds me of McDonalds - "Welcome to the AutoIt Forums, May we take your Order?" Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted May 19, 2006 Share Posted May 19, 2006 That so reminds me of McDonalds - "Welcome to the AutoIt Forums, May we take your Order?" Good one Ron!LMAO... 8 Link to comment Share on other sites More sharing options...
davykiash Posted May 19, 2006 Author Share Posted May 19, 2006 ok i am using the StringSplit function $data = StringSplit(FileReadLine ($file) ,",") ControlSend("Enter", "", "TEdit3",$data[1] ) my problem is that i dont want to use "," as the delimiter i want to use 'space' How do i go about it Link to comment Share on other sites More sharing options...
Developers Jos Posted May 19, 2006 Developers Share Posted May 19, 2006 ok i am using the StringSplit function $data = StringSplit(FileReadLine ($file) ,",") ControlSend("Enter", "", "TEdit3",$data[1] ) my problem is that i dont want to use "," as the delimiter i want to use 'space' How do i go about it $data = StringSplit(FileReadLine ($file) ," ") SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Valuater Posted May 19, 2006 Share Posted May 19, 2006 $data = StringSplit(FileReadLine ($file) ," ") like that 8) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 19, 2006 Moderators Share Posted May 19, 2006 (edited) ok i am using the StringSplit function $data = StringSplit(FileReadLine ($file) ,",") ControlSend("Enter", "", "TEdit3",$data[1] ) my problem is that i dont want to use "," as the delimiter i want to use 'space' How do i go about itThen all you need to do is take out the "," and use " "$data = StringSplit(FileReadLine($file), " ") ControlSend("Enter", "", "TEdit3", $data[1] ) Edit: Blah.. Too slow... Old age or lack of sleep ... take your pick! Edited May 19, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
davykiash Posted May 19, 2006 Author Share Posted May 19, 2006 Thanks i got it Its my first time to use the forum. gimme time to understand it Link to comment Share on other sites More sharing options...
Valuater Posted May 19, 2006 Share Posted May 19, 2006 (edited) ok i am using the StringSplit function $data = StringSplit(FileReadLine ($file) ,",") ControlSend("Enter", "", "TEdit3",$data[1] ) my problem is that i dont want to use "," as the delimiter i want to use 'space' How do i go about it and per your PM davykiash Same old Newbie question, Today, 02:22 AM http://index.php?CODE=05&act=Msg&MSID=22923&VID=in http://index.php?CODE=04&act=Msg&MID=12585&MSID=22923 Newbie Group: Members Posts: 3 Member No.: 12585 Joined: Yesterday, 12:33 AM you dont get it i am not creating GUI with autoit.The exe is already up and running. what am doing am using autoit to interface my text files with ths exe. go my question is simple.how do i use space as my delimiter? this is the answer you want $data = StringSplit(FileReadLine ($file) ," ") ControlSend("Enter", "", "TEdit3",$data[1] ) 8) EDIT glad you got it... after all that Edited May 19, 2006 by Valuater Link to comment Share on other sites More sharing options...
davykiash Posted May 19, 2006 Author Share Posted May 19, 2006 My code is working fine but i receive an error when the loop reaches the end of file. The error is "Array variable has incorrect number of subscripts or subscripts dimension range exceeded" i can tell the compiler to overide this error coz am getting the job done but is it wise? $file = FileOpen("D:\Davy\AutoScripts\enterdata.txt", 0) Run("D:\Davy\AutoScripts\enterdata\prjenter") WinWait("Enter") While 1 $data = StringSplit(FileReadLine ($file) ," ") ControlSend("Enter", "", "TEdit3",$data[1] ) ControlSend("Enter", "", "TEdit2",$data[2] ) ControlSend("Enter", "", "TEdit1",$data[3] ) If @error = -1 Then ExitLoop Send("!S") Send("{ENTER}") Wend FileClose($file) Exit Link to comment Share on other sites More sharing options...
Valuater Posted May 19, 2006 Share Posted May 19, 2006 (edited) $file = FileOpen("D:\Davy\AutoScripts\enterdata.txt", 0) Run("D:\Davy\AutoScripts\enterdata\prjenter") WinWait("Enter") While 1 $data = StringSplit(FileReadLine($file), " ") If @error = -1 Then ExitLoop ControlSend("Enter", "", "TEdit3", $data[1]) ControlSend("Enter", "", "TEdit2", $data[2]) ControlSend("Enter", "", "TEdit1", $data[3]) Send("!S") Send("{ENTER}") WEnd FileClose($file) Exit the error check needs to be after the file read you may need to seperate the three fileread- check error- stringsplit- 8) Edited May 19, 2006 by Valuater Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 19, 2006 Moderators Share Posted May 19, 2006 My code is working fine but i receive an error when the loop reaches the end of file. The error is "Array variable has incorrect number of subscripts or subscripts dimension range exceeded" i can tell the compiler to overide this error coz am getting the job done but is it wise? $file = FileOpen("D:\Davy\AutoScripts\enterdata.txt", 0) Run("D:\Davy\AutoScripts\enterdata\prjenter") WinWait("Enter") While 1 $data = StringSplit(FileReadLine ($file) ," ") ControlSend("Enter", "", "TEdit3",$data[1] ) ControlSend("Enter", "", "TEdit2",$data[2] ) ControlSend("Enter", "", "TEdit1",$data[3] ) If @error = -1 Then ExitLoop Send("!S") Send("{ENTER}") Wend FileClose($file) Exit Your error checking is off:$file = FileOpen("D:\Davy\AutoScripts\enterdata.txt", 0) Run("D:\Davy\AutoScripts\enterdata\prjenter") WinWait("Enter") While 1 $data = StringSplit(FileReadLine($file) ," ") If @error = -1 Then ExitLoop ControlSend("Enter", "", "TEdit3",$data[1] ) ControlSend("Enter", "", "TEdit2",$data[2] ) ControlSend("Enter", "", "TEdit1",$data[3] ) Send("!S") Send("{ENTER}") WEnd FileClose($file) Exit Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
davykiash Posted May 19, 2006 Author Share Posted May 19, 2006 the error still persists. it is at this line of code. ControlSend("Enter", "", "TEdit2", $data[2]) it has nothing to do with the location of the code If @error = -1 Then ExitLoop Link to comment Share on other sites More sharing options...
Valuater Posted May 19, 2006 Share Posted May 19, 2006 (edited) the error still persists. it is at this line of code. ControlSend("Enter", "", "TEdit2", $data[2]) it has nothing to do with the location of the code If @error = -1 Then ExitLoop wrong again... post the error 8) EDIT should this Run("D:\Davy\AutoScripts\enterdata\prjenter") be.. this Run("D:\Davy\AutoScripts\enterdata\prjenter.exe") Edited May 19, 2006 by Valuater Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 19, 2006 Moderators Share Posted May 19, 2006 the error still persists. it is at this line of code. ControlSend("Enter", "", "TEdit2", $data[2]) it has nothing to do with the location of the code If @error = -1 Then ExitLoopYes, it had "something" to do with the @error = -1, and to imply that we both posted the same exact thing at the same exact time, that we are both wrong is rather moronic. If your getting an error @ $data[2] then there wasn't a space or there wasn't a $data[2]!$file = FileOpen("D:\Davy\AutoScripts\enterdata.txt", 0) Run("D:\Davy\AutoScripts\enterdata\prjenter") WinWait("Enter") While 1 $data = StringSplit(FileReadLine($file) ," ") If @error = -1 Then ExitLoop If UBound($data) > 0 Then ControlSend("Enter", "", "TEdit3",$data[1] ) If UBound($data) > 1 Then ControlSend("Enter", "", "TEdit2",$data[2] ) If UBound($data) > 2 Then ControlSend("Enter", "", "TEdit1",$data[3] ) Send("!S") Send("{ENTER}") WEnd FileClose($file) ExitI sure hope you don't want more help in the future with an attitude like that, and if I'm mistaken on the attitude, take a second to read your ******* post before you hit submit, and see how it would read to you. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted May 19, 2006 Share Posted May 19, 2006 (edited) @ron... what about this $file = FileOpen("D:\Davy\AutoScripts\enterdata.txt", 0) Run("D:\Davy\AutoScripts\enterdata\prjenter") WinWait("Enter") While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $data = StringSplit($line ," ") ... bla Edited May 19, 2006 by Valuater Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 19, 2006 Moderators Share Posted May 19, 2006 (edited) @ron... what about this $file = FileOpen("D:\Davy\AutoScripts\enterdata.txt", 0) Run("D:\Davy\AutoScripts\enterdata\prjenter") WinWait("Enter") While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $data = StringSplit($line ," ") ... blaOops, I am too tired... This should fix most problems I would think:$file = FileOpen("D:\Davy\AutoScripts\enterdata.txt", 0) Run("D:\Davy\AutoScripts\enterdata\prjenter");<< are you not getting an error here? Or did you not put the actual .exe name? WinWait("Enter") $Count = 1 While 1 $line = FileReadLine($file, $Count) If @error = -1 Then ExitLoop $data = StringSplit($line ," ") If IsArray($data) Then If UBound($data) - 1 > 0 Then ControlSend("Enter", "", "TEdit3",$data[1] ) If UBound($data) - 1 > 1 Then ControlSend("Enter", "", "TEdit2",$data[2] ) If UBound($data) - 1 > 2 Then ControlSend("Enter", "", "TEdit1",$data[3] ) EndIf $Count = $Count + 1 Send("!S") Send("{ENTER}") WEnd FileClose($file) ExitoÝ÷ ØGb´Z+uiû^®Ø^Qº.اna¦-"ØbAÝiÙ²µë-·_W¢Ø^{¦¦W¬¶)eßqÝĽéÛzÛ^«¢+ØÀÌØí¥±ô¥±=Á¸ ÅÕ½ÐíèÀäÈíÙäÀäÈíÕѽMÉ¥ÁÑÌÀäÈí¹ÑÉѹÑáÐÅÕ½Ðì°À¤)IÕ¸ ÅÕ½ÐíèÀäÈíÙäÀäÈíÕѽMÉ¥ÁÑÌÀäÈí¹ÑÉÑÀäÈíÁÉ©¹ÑÈÅÕ½Ðì¤ì±Ðì±ÐìÉå½Ô¹½ÐÑÑ¥¹¸ÉɽȡÉü=È¥å½Ô¹½ÐÁÕÐÑ¡ÑÕ°¹á¹µü)]¥¹]¥Ð ÅÕ½Ðí¹ÑÈÅÕ½Ðì¤(ÀÌØí ½Õ¹ÐôÄ)]¡¥±Ä($ÀÌØí±¥¹ô¥±I1¥¹ ÀÌØí¥±°ÀÌØí ½Õ¹Ð¤(%%ÉɽÈô´ÄQ¡¸á¥Ñ1½½À($ÀÌØíÑôMÑÉ¥¹MÁ±¥Ð ÀÌØí±¥¹°ÅÕ½ÐìÅÕ½Ðì¤(%%%ÍÉÉä ÀÌØíѤQ¡¸($%½ÈÀÌØí¥½Õ¹ÐôÄQ¼Ì($$% ½¹Ñɽ±M¹ Ìäí¹ÑÈÌäì°ÌäìÌäì°ÌäíQ¥ÐÌäìµÀì Ì´ÀÌØí¥½Õ¹Ð¤°ÀÌØíÑlÀÌØí¥½Õ¹Ñt¤($%9áÐ(%¹%($ÀÌØí ½Õ¹ÐôÀÌØí ½Õ¹Ð¬Ä(%M¹ ÅÕ½ÐìÌÌíLÅÕ½Ðì¤(%M¹ ÅÕ½Ðíí9QIôÅÕ½Ðì¤)]¹)¥± ±½Í ÀÌØí¥±¤)á¥Ð Edited May 19, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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