how to poll priodically

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
grodrig
Posts: 7
Joined: Thu Mar 19, 2009 8:29 pm

how to poll priodically

Post by grodrig » Thu Oct 01, 2009 8:00 pm

In our application we connect to an external hardware via the usb port and from there to another device. We need to know that the hardware we connect to is in a certain state. We created an indicator and a button that checks this connection. It works fine thus far. Th problem is that e want the program to keep cheking on this connection every so often for as long as that particular stack is often. That is we don't want to kkeep pressing the button every 2 minutes to see ianything change. How do we do that?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Thu Oct 01, 2009 8:45 pm

Hi grodrig,
you could you a send in time construct. I ususally do it by moving the polling part of your button into a separate command

Code: Select all

on mouseUp
send polltheDevice to me in 1 millisecond
end mouseUp

on polltheDevice
-- do your polling here
-- if everything is fine then
send polltheDevice to me in 120 seconds
-- else
-- do what is appropriate without sending 
end if
end polltheDevice
this should to it.
pertaining keywords in the dictionary: send, pendingMessages
regards
Bernd

grodrig
Posts: 7
Joined: Thu Mar 19, 2009 8:29 pm

Post by grodrig » Fri Oct 02, 2009 6:52 pm

Perfect!! thanks.

Post Reply