glasglow Posted February 7, 2008 Share Posted February 7, 2008 While 1 $radek = $radek + 1 $data = FileReadLine($file_in) If @error = -1 Then ExitLoop $file_in = FileOpen('data.txt', 0) If $file_in = -1 Then MsgBox(0, "Mistake", "Nothing in this file") Exit EndIf WEnd What I have is 3 of these loops, and 3 text files. What I would like to do. The first 1, loop 1 and loop 2 will always contain the same number of rows. The second loop will always contain more rows. What I would like to do is loop through the first two and lets say get value set 1 then loop through each line of the third text file and move on to the second value set of the first two files. Any suggestions? Link to comment Share on other sites More sharing options...
glasglow Posted February 7, 2008 Author Share Posted February 7, 2008 (edited) Would it be possible instead of exiting the loop, to "Then ContinueLoop" on the first two and leave the third loop an "Exitloop"? It doesn't seem right because it seems it will go back to the beginning of the first two and not finish the third, since the third is longer... I don' want it to do that. Edited February 7, 2008 by glasglow Link to comment Share on other sites More sharing options...
Kademlia Posted February 7, 2008 Share Posted February 7, 2008 Dont realy get what you want + your code ...continueloop? Link to comment Share on other sites More sharing options...
glasglow Posted February 7, 2008 Author Share Posted February 7, 2008 Dont realy get what you want + your code ...continueloop? If I have this: While 1 $radek = $radek + 1 $data = FileReadLine($file_in) If @error = -1 Then ExitLoop $file_in = FileOpen('data1.txt', 0) If $file_in = -1 Then MsgBox(0, "Mistake", "Nothing in this file") Exit EndIf WEnd While 1 $radek = $radek + 1 $data = FileReadLine($file_in) If @error = -1 Then ExitLoop $file_in = FileOpen('data2.txt', 0) If $file_in = -1 Then MsgBox(0, "Mistake", "Nothing in this file") Exit EndIf WEnd While 1 $radek = $radek + 1 $data = FileReadLine($file_in) If @error = -1 Then ExitLoop $file_in = FileOpen('data3.txt', 0) If $file_in = -1 Then MsgBox(0, "Mistake", "Nothing in this file") Exit EndIf WEnd And data1.txt, data2.txt have 4 lines, but data3.txt has 100 lines. How can I use line 1 from data1.txt and line 1 from data2.txt and Lines 1-100 from data3.txt? Then line 2 from data1.txt and data2.txt and lines 1-100 from data3.txt again. Link to comment Share on other sites More sharing options...
Kademlia Posted February 7, 2008 Share Posted February 7, 2008 Hm think there is a better way but i would use conters. put file1 and file2 to arrays. then [pseudocode] counter = 1 counter_old = 1 bigcounter = 0 while 1 $data3 = Filereadline(data3_file) counter = counter+1 If counter = counter_old+99 then bigcounter = bigcounter+1 endif Do($data3, bigcounter) ; bigcount should be 0 from 1-99, 1 from 100-199 aso wend [/pseudocode] may be wrong with the +99 didnt test just wrote it down fast Link to comment Share on other sites More sharing options...
glasglow Posted February 7, 2008 Author Share Posted February 7, 2008 Hm think there is a better way but i would use conters. put file1 and file2 to arrays. then [pseudocode] counter = 1 counter_old = 1 bigcounter = 0 while 1 $data3 = Filereadline(data3_file) counter = counter+1 If counter = counter_old+99 then bigcounter = bigcounter+1 endif Do($data3, bigcounter) ; bigcount should be 0 from 1-99, 1 from 100-199 aso wend [/pseudocode] may be wrong with the +99 didnt test just wrote it down fast It's interesting I'll see if I can work with it, but it seems too rigid.. I mean suppose file3 had only 97 or had 103.. Link to comment Share on other sites More sharing options...
Kademlia Posted February 7, 2008 Share Posted February 7, 2008 If you just want 100 lines for every line from file 1 or2 this will work. no matter if there are 5 oder 500 lines in file 3 Link to comment Share on other sites More sharing options...
glasglow Posted February 7, 2008 Author Share Posted February 7, 2008 Do you think I could use it this way to get the desired effects? While While While WEnd WEnd WEnd Link to comment Share on other sites More sharing options...
glasglow Posted February 7, 2008 Author Share Posted February 7, 2008 (edited) If you just want 100 lines for every line from file 1 or2 this will work. no matter if there are 5 oder 500 lines in file 3The 100 was just an example. I want 1 line from file1 and file 2 and ALL the lines from file 3 regardless of how many.11All22All33AllEtc.. Edited February 7, 2008 by glasglow Link to comment Share on other sites More sharing options...
Kademlia Posted February 7, 2008 Share Posted February 7, 2008 (edited) okayyyy then u dont need all this while 1 $data1 = FileReadLine($datafile1) $data2 = FileReadLine($datafile2) while 1 $data3 = FileReadLine($datafile3) If @error then exitloop Do(xY) Wend wend Edited February 7, 2008 by Kademlia Link to comment Share on other sites More sharing options...
glasglow Posted February 7, 2008 Author Share Posted February 7, 2008 (edited) okayyyy then u dont need all thiswhile 1$data1 = FileReadLine($datafile1)$data2 = FileReadLine($datafile2)while 1$data3 = FileReadLine($datafile3)If @error then exitloopDo(xY)WendwendThank you sir, this one makes a lot of sense. I will try this one. I never thought of the logic of it like that...multiples. Edited February 7, 2008 by glasglow 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