Bookshelf Home | Contents | Index | Search | PDF |
Siebel eScript Language Reference > Siebel eScript Language Overview > Operators >
Logical Operators and Conditional Expressions
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:
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 theif
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 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
target_number = 37;
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. This is a common mistake, even among experienced programmers.
Bookshelf Home | Contents | Index | Search | PDF |
Siebel eScript Language Reference Published: 18 April 2003 |