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

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

Edited by layer

FootbaG

##### Share on other sites

thanks, i'll try on my scripts

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

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

cool =)

qq

##### Share on other sites

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 :)

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...