Skip to content

IF/THEN/ELSE/ENDIF

FUNCTION

This command conditionally performs one or more commands.

SYNTAX

IF condition THEN
command [command] ...
[ELSE
command [command] ...]
ENDIF
condition
an expression or statement that is tested to determine whether an action will be taken.
command
any Script-IV command.

NOTES

  • The logical condition is two or more values, consisting of constants, data names, variables, functions, or expressions, that interact with relational or logical operators to form a true or false result.
  • For more information on logical conditionals see the section on Logical Conditionals in this manual.
  • One or more commands can be specified in the THEN clause. These commands are executed sequentially when the condition is true.
  • The ELSE clause is optional and can specify one or more commands to be executed when the condition is false.
  • Each IF must have a corresponding ENDIF.
  • The commands can be any Script-IV command, including other IF/THEN/ELSE/ENDIF commands.

EXAMPLES

IF CUS-CODE <> "Cash " THEN
DO 7-CUST-READ
IF TERM-KEY = 4 OR INPUT-FLAG <> " " THEN
TERMINATE PROCEDURE
ENDIF
ENDIF

SEE ALSO

Section on Logical Conditionals

From the Script-IV Language Reference, version 8.9.1. Open this page in the PDF