timerArray=[createobject("roTimeSpan"),createobject("roTimeSpan"),createobject("roTimeSpan"),createobject("roTimeSpan")]
timeouts=[15,30,50,100]
exec[func1,func2,func3,func4]
while true
for i=0 to timearray.count() -1
if timeouts[i] >= timerArrray[i].totalmilliseconds() then
exec[i]()
timerArray[i].mark()
end for
end while
"RokuJoel" wrote:
or you can have an array or roTimeSpan objects and an array of execution times, and an array of functions to execute, something like this:
...
- Joel
"RokuMarkn" wrote:
You can just use a short timeout on your wait call and periodically check whether it is time to perform your action.
--Mark
"RokuMarkn" wrote:
I'm assuming your app needs to do something other than trigger the timers. It has a screen or something that it needs to manage at the same time, right? So you would just modify your existing event loop to add a timeout to wait (eg. wait(timeout, port)) and then after the wait check your timers as you said. Note that you must use a nonzero timeout or the wait will just wait until you get a keypress or other real event, which may happen after your timers need to fire. Also note that you really only need one roTimespan, which acts like a clock. Each timer needs to know what time it expires, but it doesn't need a separate roTimespan to do that, just an integer (milliseconds on the clock).
--Mark
"breger" wrote:
So I should call timer.mark() when i create the timer object. Then if I have something that has a 4 second 'delay', I should read the timeinseconds(), add 4, and save that number and use that to compare?