Siebel eScript Language Reference > Siebel eScript Language Overview > Operators in Siebel eScript >
Conditional Operator in Siebel eScript
The conditional operator, a question mark, provides a shorthand method for writing else statements. Statements using the conditional operator are more difficult to read than conventional if
statements, so they are used when the expressions in the if statements are brief.
The syntax is:
test_expression ? expression_if_true : expression_if_false
First, test_expression is evaluated. If test_expression is true, then expression_if_true is evaluated, and the value of the entire expression is replaced by the value of expression_if_true. If test_expression is false, then expression_if_false is evaluated, and the value of the entire expression is that of expression_if_false.
The following fragments illustrate the use of the conditional operator:
foo = ( 5 < 6 ) ? 100 : 200;
In the previous statement foo is set to 100, because the expression is true.
TheApplication().RaiseErrorText("Name is " + ((null==name) ? "unknown" : name));
In the previous statement, the message box displays
"Name is unknown" if the name variable has a null value. If it does not have a null value, the message box displays
"Name is " plus the content of the variable.