Siebel eScript Language Reference > Statements Reference > Guidelines for Using Siebel eScript >

If Statement


The If statement tests a condition and proceeds depending on the result.

Format A

if (condition)
   statement;

Format B

if (condition)
{
   statement_block;
}
[else if (condition)
{
   statement_block;
}]
[else
{
   statement_block;
}]

Table 23 describes the arguments for the If statement.

Table 23. Arguments for the If Statement
Argument
Description

condition

An expression that evaluates to true or false.

statement_block

If the expression is:

  • True. Siebel eScript runs the statement or statement_block.
  • False. Siebel eScript skips the statement or statement_block.
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.");

Using More Than One If Statement

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.

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