Siebel eScript Language Reference > Siebel eScript Language Overview > Operators in Siebel eScript >

Logical Operators and Conditional Expressions in Siebel eScript

Logical operators compare two values and evaluate whether the resulting expression is false or true. A variable or any other expression may be false or true. An expression that performs a comparison is called a conditional expression.

Logical operators are used to make decisions about which statements in a script are executed, based on how a conditional expression evaluates.

The logical operators available in Siebel eScript are described in Table 10

Table 10. Logical Operators in Siebel eScript



Reverse of an expression. If (a+b) is true, then !(a+b) is false.



True if, and only if, both expressions are true. Because both expressions must be true for the statement as a whole to be true, if the first expression is false, there is no need to evaluate the second expression, because the whole expression is false.



True if either expression is true. Because only one of the expressions in the or statement needs to be true for the expression to evaluate as true, if the first expression evaluates as true, the Siebel eScript interpreter returns true and does not evaluate the second.



True if the values are equal; otherwise false. Do not confuse the equality operator, ==, with the assignment operator, =.



True if the values are not equal; otherwise false.


Less than

The expression a < b is true if a is less than b.


Greater than

The expression a > b is true if a is greater than b.


Less than or equal to

The expression a <= b is true if a is less than or equal to b.


Greater than or equal to

The expression a >= b is true if a is greater than b.

For example, if you were designing a simple guessing game, you might instruct the computer to select a number between 1 and 100, and you would try to guess what it is. The computer tells you whether you are right and whether your guess is higher or lower than the target number.

This procedure uses the if statement, which is introduced in the next section. If the conditional expression in the parenthesis following an if statement is true, the statement block following the if statement is executed. If the conditional expression is false, the statement block is ignored, and the computer continues executing the script at the next statement after the ignored block.

The script implementing this simple guessing game might have a structure similar to the one that follows, in which GetTheGuess() is a function that obtains your guess.

var guess = GetTheGuess(); //get the user input, either 1, 2, or 3
target_number = 2;
if (guess > target_number)
   TheApplication().RaiseErrorText("Guess is too high.");
if (guess < target_number)
   TheApplication().RaiseErrorText("Guess is too low.");
if (guess == target_number);
   TheApplication().RaiseErrorText("You guessed the number!");

This example is simple, but it illustrates how logical operators can be used to make decisions in Siebel eScript.

CAUTION:  Remember that the assignment operator, =, is different from the equality operator, ==. If you use the assignment operator when you want to test for equality, your script fails because the Siebel eScript interpreter cannot differentiate between operators by context. Using the assignment operator incorrectly is a common mistake, even among experienced programmers.

Siebel eScript Language Reference