switch/case/wait
The following code doesnt work. It seems that the switch/case statement doesnt work inside the wait.
Strange though that if I change it to select/active it will work.
I tried assigning 'mode' to a local var but that didnt work either.
I suppose there is a perfectly valid reason why this doesnt work. I'll have to make sure I dont get caught on it next time.
Strange though that if I change it to select/active it will work.
I tried assigning 'mode' to a local var but that didnt work either.
I suppose there is a perfectly valid reason why this doesnt work. I'll have to make sure I dont get caught on it next time.
define_function systemStartup (char mode) //1=standard, 2=recorded, 3=video conf
{
switch(mode)
{
case 1:{ //standard
send_string 0,"'First switch - case = 1'";
}
case 2:{ //recorded
send_string 0,"'First switch - case = 2'";
}
case 3:{ //video conf
send_string 0,"'First switch - case = 3'";
}
default:{
send_string 0,"'First switch - case defaulted'";
}
}
if (systemStatus = systemIsOff)
{
switch(mode)
{
case 1:{ //standard
send_string 0,"'2nd switch - case = 1'";
}
case 2:{ //recorded
send_string 0,"'2nd switch - case = 2'";
}
case 3:{ //video conf
send_string 0,"'2nd switch - case = 3'";
}
default:{
send_string 0,"'2nd switch - case defaulted'";
}
}
systemStatus = systemIsOn;
}
else
{
wait 30{
switch(mode)
{
case 1:{ //standard
send_string 0,"'3rd switch - case = 1'";
}
case 2:{ //recorded
send_string 0,"'3rd switch - case = 2'";
}
case 3:{ //video conf
send_string 0,"'3rd switch - case = 3'";
}
default:{
send_string 0,"'3rd switch - case defaulted'";
}
}
systemStatus = systemIsOff;
}
}
}
Assign Stack Ref Error - Out of Range CHeap::Delete - ERROR(2) Attempting to delete invalide block 3rd switch - case defaulted
0
Comments
There is no valid reason that I?m aware of. It's just one of the switch/case ?undocumented features.?
Correct me if I'm wrong, but isn't Select/Active a structure exclusive to NetLinx? I've never seen it in any other language, and Google is coming up empty as well.
DEFINE_DEVICE dvTP = 10001:1:0 DEFINE_VARIABLE INTEGER nTest = 1 DEFINE_FUNCTION fnWaitTestSwitch() { SEND_STRING 0, 'Entering fnWaitTestSwitch' WAIT 10 { SWITCH (nTest) { CASE 1: { SEND_STRING 0, 'WaitTestCase 1' } CASE 2: { SEND_STRING 0, 'WaitTestCase 2' } } } } DEFINE_FUNCTION fnWaitTestSelelct() { SEND_STRING 0, 'Entering fnWaitTestSelelct' WAIT 10 { SELECT { ACTIVE(nTest = 1): { SEND_STRING 0, 'WaitTestActive 1' } ACTIVE(nTest = 2): { SEND_STRING 0, 'WaitTestActive 2' } } } } DEFINE_EVENT BUTTON_EVENT[dvTP,1] { PUSH: { fnWaitTestSwitch() } } BUTTON_EVENT[dvTP,2] { PUSH: { fnWaitTestSelelct() } }Incorrect output when Button 1 is pushed:
Correct output when Button 2 is pushed: