Jump to content

Multiple Loops


 Share

Recommended Posts

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

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 by glasglow
Link to comment
Share on other sites

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

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

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

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

The 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.

1

1

All

2

2

All

3

3

All

Etc..

Edited by glasglow
Link to comment
Share on other sites

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 by Kademlia
Link to comment
Share on other sites

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

Thank 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 by glasglow
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...