Jump to content

loop inside an infinte loop Qestion


Recommended Posts

hi,

is it possible to have a loop in an infinite loop?

eg.

while 1 = 1

loop 20

procedure 1

loop15

procedure 2

loop 2

procedure 3

Wend

i want procedure 1 to be repeat 20 time then it start on procedure 2 for 15 times then do procedure 3 for 2 time2 and repeat all over again in an infinite loop. is it possible? can someone give me a hand?

thanks a lot. :)

Link to comment
Share on other sites

You can have a Do...Until loop inside a While loop, or even a For...Next loop. Example:

While 1
For $i = 5 to 1 step -1
MsgBox(0, $i, $i)
Next
MsgBox(0, "Lift off!", "Huston, we have lift off.")
Wend

That will run a For...Next loop inside of a While...WEnd loop. I don't think it's possible to run a While...WEnd loop inside of another While...WEnd loop, it doesn't even make sense. :)

EDIT: Now I see what your saying... The above example I provided should get you off on the write track :D

Edited by layer
FootbaG
Link to comment
Share on other sites

Do...Until

$a = 0
$b = 0
$c = 0

While 1
   Do
    ;Procedure 1
      $a =  $a + 1
   Until $a = 20
   Do
     ;Procedure 2
      $b =  $b + 1
   Until $b = 15
   Do
     ;Procedure 3
      $c =  $c + 1
   Until $c = 2
   $a = 0
   $b = 0
   $c = 0
Wend

For...Next

While 1
   For $i = 20 to 1 step -1
    ;Procedure 1
   Next
   For $i = 15 to 1 step -1
    ;Procedure 2
   Next
   For $i = 2 to 1 step -1
    ;Procedure 3
   Next
Wend

not sure if u can use the same constant variable $i for each loop, maybe have to change

While Loop

$a = 0
$b = 0
$c = 0

While 1
   While $a <> 20
    ;Procedure 1
      $a = $a + 1
   Wend
   While $b <> 15
    ;Procedure 1
      $b = $b + 2
   Wend
   While $c <> 2
    ;Procedure 3
      $c = $c + 1
   Wend
   $a = 0
   $b = 0
   $c = 0
Wend

:), what ever floats your boat

Edited by burrup

qq

Link to comment
Share on other sites

While 1
   For $i = 20 to 1 step -1
    ;Procedure 1
   Next
   For $i = 15 to 1 step -1
    ;Procedure 2
   Next
   For $i = 2 to 1 step -1
    ;Procedure 3
   Next
Wend

not sure if u can use the same constant variable $i for each loop, maybe have to change

The $i used in your example, is a local (counter) variable in For loops. So your example is OK. :)
Link to comment
Share on other sites

  • 6 years later...

That will run a For...Next loop inside of a While...WEnd loop. I don't think it's possible to run a While...WEnd loop inside of another While...WEnd loop, it doesn't even make sense. :)

EDIT: Now I see what your saying... The above example I provided should get you off on the write track ;)

I know this is far dead, im just amazed how far we have come

muppet hands are so soft :)

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