Question
· Feb 11, 2017

What is the difference between $case and $select?

What is the difference between $case and $select?.Where places to use $case and $select?

Discussion (1)0
Log in or sign up to continue

$case is used to convert one value to another. Like, you have some code, but you need a display text for it, you can do so:

set display=$case(gender,"F":"Female","M","Male",:"Unknown")

$select returns value when meets the first true condition. It needs if can't compare only one variable, or you have some more conditions.

write $SELECT(0=$ISVALIDNUM(x):"not a number",x=0:"zero",""=$NUMBER(x,"I"):"not an integer",x#2=1:"odd",1:"even")