User Tools

Site Tools


if_conditional_execution_structure_.htm
Navigation:  Language Reference > 12 - Execution Control > Control Structures >====== IF (conditional execution structure) ====== Previous pageReturn to chapter overviewNext page

 

IF logical expression [ THEN ]

statements

[ ELSIF logical expression [ THEN ]

statements ]

[ ELSE

statements ]

END

blk2blue.jpg

IF Initiates a conditional statement execution structure.
logical expression A variable, procedure, or expression which evaluates a condition. Control is determined by the result (true or false) of the expression. Zero (or blank) evaluates as false, anything else is true.
THEN The statements following THEN execute when the preceding logical expression is true. If used, THEN must only appear on the same line as IF or ELSIF.
statements An executable statement, or a sequence of executable statements.
ELSIF The logical expression following an ELSIF is evaluated only when all preceding IF or ELSIF conditions were evaluated as false.
ELSE The statements following ELSE execute only when all preceding IF and ELSIF options evaluate as false. ELSE is not required, however, when used, it must be the last option in the IF structure.

An IF structure controls program execution based on the outcome of one or more logical expressions. IF structures may have any number of ELSIF statement groups. IF structures may be “nested” within other executable structures. Other executable structures may be nested within an IF structure. Each IF structure must terminate with an END statement (or period).

Example:

IF Cus:TransCount = 1                              !If new customer

AcctSetup                                         !call account setup procedure

ELSIF Cus:TransCount > 10 AND Cus:TransCount <; 100 !If regular customer

DO RegularAcct                                    !process the account

ELSIF Cus:TransCount > 100                         !If special customer

DO SpecialAcct                                    !process the account

ELSE                                               !Otherwise

DO NewAcct                                        !process the account

IF Cus:Credit

 CheckCredit

ELSE

 CLEAR(Cus:CreditStat)

END

! verify credit status

END    

IF ERRORCODE()

ErrHandler(Cus:AcctNumber,Trn:InvoiceNbr)         !Handle errors

END

See Also:

EXECUTE

CASE

if_conditional_execution_structure_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1