How to execute / trigger commands in some interval.
davidgev
Posts: 9
Hi Guys,
Can you please suggest a way to execute / trigger commands in some interval, namely when a specified amount of time has elapsed?
I have tried below code, but it didn't work:
WHILE (TRUE)
{
SEND_STRING 0,"'Inside the while loop ...'"
WAIT 10 'FIRST WAIT'
{
SEND_STRING 0,"'After the first wait ...'"
}
}
The thing is that execution of the SEND_STRING 0,"'After the first wait ...'" isn't performed, and the only thing I get is a bunch of "Inside the while loop ..." string, when debugging.
I just want to repeatedly execute code enclosed in the outer WAIT scope. Can anyone please explain why this doesn't work and how else can I do that?
Thanks in advance,
David Gevorkyan
Can you please suggest a way to execute / trigger commands in some interval, namely when a specified amount of time has elapsed?
I have tried below code, but it didn't work:
WHILE (TRUE)
{
SEND_STRING 0,"'Inside the while loop ...'"
WAIT 10 'FIRST WAIT'
{
SEND_STRING 0,"'After the first wait ...'"
}
}
The thing is that execution of the SEND_STRING 0,"'After the first wait ...'" isn't performed, and the only thing I get is a bunch of "Inside the while loop ..." string, when debugging.
I just want to repeatedly execute code enclosed in the outer WAIT scope. Can anyone please explain why this doesn't work and how else can I do that?
Thanks in advance,
David Gevorkyan
0
Comments
and see what happens.
My guess about the code that you wrote is that the first send_string occurs about 1000 times per second and you just don't notice the other string that pops up every second, but that's just my guess.
I don't think that there's anything wrong with doing this sort of thing in define_program, but in general, it's probably better to use a time line -- particularly if you're trying to code that !#(%#%& test program. Of course, if you're trying to program an Axcent 2 that you bought off Ebay for $1.75, time lines are not your solution.
Your guess isn't correct, since I have commented out the:
but still there is no sign of entering and executing code inside the WAIT.
Can you please send me an example of time line? Can I specify an [highlight]Interval[/highlight] there and a [highlight]Function[/highlight] that should be executed as the specified amount of time elapses?
Jeff
They are very flexible and can easily be manipulated.
This code doesn't work because you created an endless loop with the while statement, so the processor never is able to check for expired waits. If you change your WHILE statement to an IF statement it should work as you intended, however, in this case a Timeline might be a better choice.
--D
I have used TIMELINE and it worked perfectly.
Here is some code snippet:
Sincerely,
David Gevorkyan
What your trying to do is best handled by creating a QUEUE. Search through the forum looking for the term "QUEUE". You will find a bunch of ideas how to do this correctly.
// Here is a nice conversation on queueing...
http://www.amxforums.com/showthread.php?t=5372&highlight=Queue