Example of Using Logical Operators and Conditional Expressions
Assume you design a simple guessing game where you configure Siebel CRM to choose a number between 1 and 100, and the user attempts to guess the value of this number. The game provides feedback if the user is correct or if the user answer is higher or lower than the number that the game chooses. The following Siebel eScript code implements this guessing game. Assume that the GetTheGuess function is a custom function that gets the guess:
var guess = GetTheGuess(); //get the user input, which is 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!”);
}
In this example, the action that Siebel eScript performs depends on if the value in the parenthesis in an If statement is true or false:
True. It runs the statement block that follows this If statement.
False. It ignores the statement block that follows this If statement and runs the script that occurs immediately after the statement block.