Siebel eScript Language Reference > Using Siebel eScript > Using Operators in Siebel eScript >

Using Less Code to Write an Else Statement


The conditional operator is a type of operator that allows you to use less code when you write an Else statement. A statement that includes a conditional operator is more difficult to read than an If statement. It is recommended that you use a conditional operator only if the expressions in the If statements are brief.

The following format illustrates how the question mark (?) represents the conditional operator:

variable = expressionA ? expressionC : expressionC

where:

  • expressionA is the expression that Siebel eScript evaluates first.
  • expressionB is the expression that Siebel eScript evaluates if expressionA is true. If expressionA is true, then Siebel eScript replaces the value of the entire expression with the value of expressionB.
  • expressionC is the expression that Siebel eScript evaluates if expressionA is true. If expressionA is false, then Siebel eScript replaces the value of the entire expression with the value of expressionC.

To use less code to write an Else statement

  • Use a conditional operator instead of an Else statement.

Examples of Using the Conditional Operator

In the following example, the expression is true and Siebel eScript sets the value of variableA to 100:

variableA = ( 5 < 6 ) ? 100 : 200;

Consider the following example:

TheApplication().RaiseErrorText("Name is " + ((null==name) ? "unknown" : name));

If the name variable contains:

  • A null value, then Siebel CRM displays the following text:

    Name is unknown

  • A value that is not null, such as Pat, then Siebel CRM displays the following text:

    Name is Pat

Siebel eScript Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.