case
This feature is new in Ignition version 7.8.1
This function acts like the switch statement in C-like programming languages. It takes the value argument and compares it to each of the case1 through caseN expressions. If value is equal to caseX , then case returns valueX . If value is not equal to any of the case1..N , then returnDefault is returned.
Note that case() is similar in functionality to the switch() expression function . The difference between the two is the order in which the parameters are passed.
case( value, case1, return1, case2, return2, ...caseN, returnN, returnDefault )
//The following would return 46 because the value (15) matched case 3, so the third return (46) was returned.
case
(
15
,
// value
1
,
// case 1
44
,
// return 1
24
,
// case 2
45
,
// return 2
15
,
// case 3
46
,
// return 3
-
1
)
// default
//The following would return "Running".
case
(
1
,
// value
0
,
// case 1
"Off"
,
// return 1
1
,
// case 2
"Running"
,
// return 2
2
,
// case 3
"Fault"
,
// return 3
forceQuality(
"!BAD STATE!"
,
0
))
// default