Jump to content

Do Until, with a sleep?


Glyph
 Share

Recommended Posts

$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

Link to comment
Share on other sites

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

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