WAIT - Should I name it?
Spire_Jeff
Posts: 1,917
Here is a tip that might be useful:
Here is the thread where this appeared in case you want an example of when this might be useful: http://amxforums.com/showthread.php?postid=5178 *NEW LINK*
Jeff
DHawthorne wrote:Named waits will not call a new iteration if the previous has not been canceled or expired.
Here is the thread where this appeared in case you want an example of when this might be useful: http://amxforums.com/showthread.php?postid=5178 *NEW LINK*
Jeff
0
Comments
I used to have problems with devices sending a gazillion and a half IR pulses if I pressed a button multiple times without using a WAIT name & and not cancelling my wait. Sometimes, the sequence of IRs would continue for a couple of minutes. Good idea to share the whole naming of WAITs!!
(EDIT) - Links works fine. Was saying I wasn't logged in - but I was. After it prompted me to log in again and I did, it worked. Strange . . . must be a bug.
The only reason to name a wait is if you have a need to cancel it.
I use
WAIT 5 {nFlash = !nFlash}
in Mainline of just about every program I write. If unnamed WAIT's allowed multiple instances, the variable nFlash would toggle at the rate that Mainline was being scanned (which doesn't happen).
--D
If your code has something like this:
WAIT 50
(do something)
WAIT 50
(do something else)
WAIT 50
(do another thing)
...all three things will happen, at the same time.
If your code says:
WAIT 'TEST' 50
(do something)
WAIT 'TEST' 50
(do something else)
WAIT 'TEST' 50
(do another thing)
...only the first thing will happen. The other WAITs, having the same name, will not take effect because a WAIT with the same name is already active.
If your code says:
WAIT 'TEST1' 50
(do something)
WAIT 'TEST2' 50
(do something else)
WAIT 'TEST3' 50
(do another thing)
...all three will happen at the same time. It's the same as leaving them unnamed.
Edit: corrected as per Brian's observation below
I think this will do what I want without me having to write a timelines or track when the last message was sent. Does this seem logical, or am I misinterpreting the implementation?
Jeff
That little tale aside, I only use waits for the simplest things in NetLinx. What you are describing, I would go ahead and make a timeline for it. For something like that, killing and restarting a timeline is trivial.
This isn't quite correct. All three WAIT's will execute at the same time 5 seconds later. They are not nested, and each is handled separately.
--D