If function

Syntax

If condition Then
   statement_list
[Else
   statement_list]
End-If

Description

Use the If statement to execute statements conditionally, depending on the evaluation of a conditional expression. The Then and Else clauses of an If consist of arbitrary lists of statements. The Else clause may be omitted. If condition evaluates to True, all statements in the Then clause are executed; otherwise, all statements in the Else clause are executed.

Example

The following example’s first If statement checks for BEGIN_DT and RETURN_DT, and makes sure that RETURN_DT is greater (later) than BEGIN_DT. If this is True, the execution continues at the following line, otherwise execution continues at the line beginning with WinMessage:

If All(BEGIN_DT, RETURN_DT) AND
      BEGIN_DT = RETURN_DT Then
   &DURATION_DAYS = RETURN_DT - BEGIN_DT;
   If &DURATION_DAYS  999 Then
      DURATION_DAYS = 999;
   Else
      DURATION_DAYS = &DURATION_DAYS;
   End-if;
Else
   WinMessage("The beginning date is later then the return date!");
End-if;

Related Topics