Trail: PROIV Documentation > Developer > PROIV Developer > Developing Functions > Events and Logic > IF THEN ELSE ENDIF

 

 

Purpose

IF THEN ELSE ENDIF tests for a condition and continues accordingly.
 

Syntax

Format 1

IF
expression {THEN
                statement(s)}
{ELSE
                statement(s)}
ENDIF



Format 2


IF
variable {THEN
               
statement(s)}
{ELSE
               
statement(s)}
ENDIF

 

Operation

expression is any logical expression that can be evaluated as either true or false
variable
 is any numeric or alphanumeric variable that can be evaluated as either true or false
 

Remarks

A semi-colon (;) may be used in place of ENDIF.

It is strongly recommended that a method of indentation such as that used above be standard practice in design.  In instances of complex logic indentation can make it much easier to read.

Format 1:
The logical expression is evaluated. 
If it is TRUE, the statements following THEN are executed. 
If it is FALSE and an ELSE statement block exists, the ELSE block is executed.

Format 2:
A numeric variable results in a TRUE condition if it is non-zero and FALSE if it is zero.
An alphanumeric variable results in a TRUE condition if the first (leftmost) or only byte of the variable is equal to ‘Y’.  It results in a FALSE condition if it has any other value.

If a TRUE condition is reached, the statements following THEN are executed. 
If FALSE, and an ELSE statement block exists the ELSE block is executed.
 

Example

IF INVOICE-STATUS = ‘Y’
       $STATUS = ‘POSTED’
ELSE
       $STATUS = ‘NOT POSTED’
ENDIF

If INVOICE-STATUS is ‘Y’ then $STATUS is set to ‘POSTED’;
if INVOICE‑STATUS is not set to ‘Y’ then $STATUS is set to ‘NOT POSTED’.
 

Comment on this topic

Topic ID: 520065