Jump to content
Sign in to follow this  
Glyph

Do Until, with a sleep?

Recommended Posts

Glyph

$i=0    
Do
            $i=$i+1
            sleep(10)
        until $data = "err" or $i = "200" ; wait for "err" for 2 seconds
        if $i = "200" Then ; if time has expired then tell us it failed!
            gUICtrlSetData($window,"User denied: "&$connect[2]&@crlf&GUICtrlRead($window))
            $i=0
        else
            ;we got teh packet "err" tell us!
        GUICtrlSetData($window,$data&" from: "&$connect[2]&@crlf&GUICtrlRead($window))
        GUICtrlSetData($window,"User accepted: "&$connect[2]&@crlf&GUICtrlRead($window))
        $i=0
        EndIf

After my program gets a udp packet from somewhere, it will initaite this do until... which is after the case statement.

So, basically listen for x data, if you find x data then, it will start this do until.

If you then get the packet "err" then it will update in the edit box, if not... then it should tell me it was denied, but wait for the packet for 2 seconds first before giving up!

Well, all this does is sleep 2 seconds and give up! (denied message)

I'm out of ideas.... help!


tolle indicium

Share this post


Link to post
Share on other sites
Glyph

Fixed it:

$timer = TimerInit()
AdlibEnable("Timer", 50)
        Do
    $data2 = UDPRecv($socket, 256)
        until $data2 = "err" or $secs >= "05"
        
        if not $data2 = "err" and $secs >= "05" Then ; if time has expired then tell us it failed!
            AdlibDisable()
            $secs = "0"
            gUICtrlSetData($window,"User denied: "&$connect[2]&@crlf&GUICtrlRead($window))
        EndIf
        
        if $data2 = "err" and $secs < "05" Then
            AdlibDisable()
            $secs = "0"
            ;we got teh packet "err" tell us!
        GUICtrlSetData($window,$data&" from: "&$connect[2]&@crlf&GUICtrlRead($window))
        GUICtrlSetData($window,"User accepted: "&$connect[2]&@crlf&GUICtrlRead($window))

        EndIf
Edited by BackStabbed

tolle indicium

Share this post


Link to post
Share on other sites
Pioneer5250

is $data being updated properly before the loop and how do you update $data with the value "err" while in the loop

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  

×

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.