Wait with Vars
adys
Posts: 395
Hi all
I need to make this code to work with a delay between every loop iteration:
SET_VIRTUAL_PORT_COUNT (Panel.NUMBER:1:Panel.SYSTEM,PORT_COUNT)
for(port=1;port<=PORT_COUNT;port++)
{
SET_VIRTUAL_CHANNEL_COUNT (Panel.NUMBER : port: Panel.SYSTEM,CHANNEL_COUNT)
}
So the simples way is to put wait in the loop: WAIT 5 SET_VIRTUAL_CHANNEL_COUNT (Panel.NUMBER : port: Panel.SYSTEM,CHANNEL_COUNT)
But its not so simple. The Port and the Panel are stack vars, and if I am changing them to be members or local vars, the loop will change their value before the wait will happen.
Any idea how to implement this without moving to hard coded solution?
Thanks
Ady.
I need to make this code to work with a delay between every loop iteration:
SET_VIRTUAL_PORT_COUNT (Panel.NUMBER:1:Panel.SYSTEM,PORT_COUNT)
for(port=1;port<=PORT_COUNT;port++)
{
SET_VIRTUAL_CHANNEL_COUNT (Panel.NUMBER : port: Panel.SYSTEM,CHANNEL_COUNT)
}
So the simples way is to put wait in the loop: WAIT 5 SET_VIRTUAL_CHANNEL_COUNT (Panel.NUMBER : port: Panel.SYSTEM,CHANNEL_COUNT)
But its not so simple. The Port and the Panel are stack vars, and if I am changing them to be members or local vars, the loop will change their value before the wait will happen.
Any idea how to implement this without moving to hard coded solution?
Thanks
Ady.
0
Comments
Then, in your button_event or what have you, call setChanCounts(1,CHANNEL_COUNT,PORT_COUNT)
Hope that works for you.
// Option 1
// Option 2
Jeff that is a good one. the only problem is that its online event that listen to 14 TPs so I need to change it a little, but thats a good idea.
The recursion is also an option, maybe I will try it.
The reason for the wait is that I am probably loosing some of the messages when my TP gets online, and some TPs works fine and some are not :http://www.amxforums.com/showthread.php?t=3754
Must do the maximum to make sure this is not the problem..
If you're just trying to slow down the loop, you might be able to put it in a timeline.
WAITs do not work within a for loop.
I wish Netlinx FOR loops worked like old BASIC loops in that you had to put a 'NEXT' command in the loop to trigger the next loop cycle. a lot of BASIC interpretors also would allow you to leave it out and the compiler would assume a NEXT at the end of the command structure. So, if you just wanted the loop to run at 'thread' speed, it would. But if you did need to introduce a little bit of dealy it was no big deal.
When debugging the loop, everything is working cause its a "slow" loop...
If you don't have any other feedback statements to go under the wait I would probably swap the "wait" and the "if" so tha the processor isn't always maintaining a wait for a statement that will always evaluate as false except after a reboot.
it could be a goo way to make a loop, you can change the "waiting" time between events changing timeline times array... maybe you should think about this ?