# Need help with Counted Sequence?

## Recommended Posts

So I'm trying to operate a WHILE 1 statement and ideally it would run 20 times before continuing to another part of the script. First, I don't know how to designate that it occur 20 times, and second I don't know how to tell it to go to another part of the script when 20 cycles have completed. Can anyone help?

##### Share on other sites

WHILE is not designed to run a sequence 20 times. It is supposed to run a sequence as long as a certain assesment is TRUE.

a = 1

WHILE a<10

a = a+1

WEND

will run the sequence 9 times then will exit.

If you want to execute somethibg 20 times, use FOR i=1 to 20 DO

It is design for that.

Edited by happyuser

##### Share on other sites

WHILE is not designed to run a sequence 20 times. It is supposed to run a sequence as long as a certain assesment is TRUE.

a = 1

WHILE a<10

a = a+1

WEND

will run the sequence 9 times then will exit.

If you want to execute somethibg 20 times, use FOR i=1 to 20 DO

It is design for that.

so how would i designate a DO IT statement?

##### Share on other sites

Maybe....

```Dim \$x

While 1
\$x = \$x + 1

If \$x <= 20 Then
Do_This()
EndIf

If \$x >= 21 Then
Start_This(\$x)
EndIf

; start all over
If \$x >= 40 Then \$x = 0

WEnd

; --- Functions ----

Func Do_This()
MsgBox(0x0, \$x, " Count is " & \$x, 2)
EndFunc   ;==>Do_This

Func Start_This(\$in)
MsgBox(0x0, \$in, " Count is " & \$in, 2)
EndFunc   ;==>Start_This```

8)

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

×

• Wiki

• Back

• Git

## Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.