Sign in to follow this  
Followers 0
mianz

two while statement running at the same time?

4 posts in this topic

hi guys. i have this problem. i know it's a very common problem but i don't know how to search for it.

global $startstop

While 1

$nMsg = GUIGetMsg()

startbutton on click

-> call function

-> if $startstop = start then $startop = stop else $starstop = start

Wend

function abc()

while $startstop = "start"

blah blah

endfunc

ok, i know the computer is looping around function abc(), it is not detecting if startbutton is being click or not anymore. any tricks?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You need to change place between "abc()" and "if $startstop etc" and use OnEventMode. If you don't get it to work then make a small runnable reproducer and post that so we can help you.

Edit: or do what bluelamp did :P

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Opt("GUIOnEventMode", 1)

GUICreate("t",400,400)
GUISetOnEvent(-3,"_EXIT")
GUIctrlSetOnEvent(GUICtrlCreateButton("Click",200,200,100),"_POLLING")

global $startstop = 0
GUISetState(@SW_SHOW)
While 1
    Sleep(1000)
    abc()
Wend

Func _EXIT()
    Exit
EndFunc
    
Func _POLLING()
    if $startstop == 1 Then
        $startstop = 0 
    else 
        $startstop = 1
    EndIf
EndFunc

func abc()
    $i=0
    while $startstop == 1
        ConsoleWrite($i&@CRLF)
        $i+=1
    WEnd
endfunc

This is an example how you could do it

Edited by bluelamp

Share this post


Link to post
Share on other sites

yeah. oneventmode works like a charm, still buggy. will update it's status

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  
Followers 0