Jump to content

Stop While Loop


Dieuz
 Share

Recommended Posts

How can I terminate a while loop using a different button?

$Stop = False

;Gui Here

While 1

    $msg = GUIGetMsg()

    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button1
            Start()
        Case $msg = $Button2
            Stop()

    EndSelect


WEnd

Func Start()

  While $Stop = false
  ; Do stuff
  Wend

EndFunc

Func Stop()

       $Stop = true

EndFunc

Thanks,

Dieuz

Edited by Dieuz
Link to comment
Share on other sites

;Gui Here
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button1
            Start()
    EndSelect
WEnd

Func Start()
  While 1
 If GUIGetMsg() = $Button2 Then ExitLoop
 ; Do stuff
  Wend
EndFunc

Link to comment
Share on other sites

try

ExitLoop [level]

Parameters

level [optional] The number of loop levels to exit from. The default is 1 (meaning the current loop).

Remarks

A negative level or zero value has no effect.

ExitLoop will break out of a While, Do or For loop.

ExitLoop is useful when you would otherwise need to perform error checking in both the loop-test and the loop-body.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

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