If Statement
The If statement tests a condition and proceeds depending on the result.
Format A
if (condition)
statement;
if (condition)
{
statement_block;
}
[else if (condition)
{
statement_block;
}]
[else
{
statement_block;
}]
The following table describes the arguments for the If statement.
Argument | Description |
---|---|
condition |
An expression that evaluates to true or false. |
statement_block |
If the expression is:
|
Usage
If you require multiple statements, then use Format B.
The following example includes an If statement:
if ( i < 10 )
{
TheApplication().RaiseErrorText("i is less than 10.");
}
If Siebel eScript runs only a single If statement, then the curly brackets are not required. You can use them to clarify your code.
Else Clause
The else clause is an extension of the If statement. It allows you to run code if the condition in the If statement is false. The following example includes the else clause:
if ( i < 10 )
TheApplication().RaiseErrorText("i is less than 10.");
else
TheApplication().RaiseErrorText("i is not less than 10.");
If you require more than one If statement, then you must use curly brackets to group the statements. For example:
if ( i < 10 )
{
i += 10;
TheApplication().RaiseErrorText ("Original i was less than 10, and has now been
incremented by 10.");
}
else
{
i -= 5;
TheApplication().RaiseErrorText ("Original i was at least 10, and has now been
decremented by 5.");
}
This example includes an else clause in an If statement. This If statement tests for multiple conditions.
Example
The following example includes an else clause:
if ( i < 10 )
{
TheApplication().RaiseErrorText("i is less than 10.")
}
else if ( i > 10 )
{
TheApplication().RaiseErrorText("i is greater than 10.");
}
else
{
TheApplication().RaiseErrorText("i is 10.");
}
For another example, see Set Time Method.
For more information, see Switch Statement.