Hello,
I have a basic question, is there a VEX command similar to the
Switch (myVar)
{
case value1 :
do stuff;
break
case value2 :
do stuff;
break
case value3 :
do stuff;
break
}
we used in C ?
I skimmed the help and the forum, couldn't find anything…
Thanks,
Y.
Vex : Switch and case syntax?
6135 2 0-
- Yann_P
- Member
- 13 posts
- Joined: Jan. 2015
- Offline
-
- BabaJ
- Member
- 2141 posts
- Joined: Sept. 2015
- Offline
There isn't a switch equivalent.
You have to build your own ‘equivalent’.
You could use a series of if conditionals and a ‘master’ variable that indicates when one of those ifs has already been executed e.g.
Or, you could make use of a struc in which a function is called to ‘index’ another function that encapsulates what is to happen for that index value.
You have to build your own ‘equivalent’.
You could use a series of if conditionals and a ‘master’ variable that indicates when one of those ifs has already been executed e.g.
int If_Already_Executed = 0;
...
...
if( (myVar == 5) && ( If_Already_Executed == 0 ))
{
//Do stuff because of and related to value1
If_Already_Executed = 1;
}
...
...
Or, you could make use of a struc in which a function is called to ‘index’ another function that encapsulates what is to happen for that index value.
Edited by BabaJ - Sept. 19, 2018 11:35:03
-
- Yann_P
- Member
- 13 posts
- Joined: Jan. 2015
- Offline
-
- Quick Links