If

If is used to perform tests in a script.

Syntax

 If NUMERIC_EXPRESSIONlist_of_instructions_ifEndifIf NUMERIC_EXPRESSIONlist_of_instructions_ifElselist_of_instructions_elseEndifIf NUMERIC_EXPRESSIONlist_of_instructions_ifElsif NUMERIC_EXPRESSIONlist_of_instructions_elsifEndifIf NUMERIC_EXPRESSIONlist_of_instructions_ifElsif NUMERIC_EXPRESSIONlist_of_instructions_elsifElselist_of_instructions_elseEndif

Examples

# First exampleIf I=1# Line executed if I=1Else# Line executed if I is not equal to 1Endif# Second exampleIf find(CHOICE,"YES","SURELY","CERTAINLY","PERHAPS","MAYBE","POSSIBLY")# If CHOICE is in the values listed, find returns the rank in the list and this branch will be executedElse# If CHOICE is out of the list, find returns 0 and this branch will be executedEndif# More complex alternativeIf I=1# Line executed if I=1Elsif I=2 or I=1# Line executed only if I=2 (the first branch has been executed if I=1)Elsif func STRANGE(I)=3# Line executed if the condition is fulfilled. Take care, I might have been modified by Funprog STRANGEElsif I=1 or I=3# Line executed if I was not equal to 1 and 2, if the condition STRANGE(I)=3 was false,# buf if I is equal to 1 or 3 after execution of STRANGE SubprogElse# Line executed in all other casesEndif

Description and comments

See also

Else, Elsif, Endif.