Jump to content
Sign in to follow this  
David422

Need help with Counted Sequence?

Recommended Posts

David422

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 this post


Link to post
Share on other sites
happyuser

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 this post


Link to post
Share on other sites
David422

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 this post


Link to post
Share on other sites
Valuater

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)


NEWHeader1.png

Share this post


Link to post
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
Sign in to follow this  

×