IF statement

The general form for the IF statement is:

IF(logical_expression) simple_statement

For example the statement:

IF(x<0.0) x=-x

makes x positive.

Logical expressions are formed using relational operators and logical operators knowing their order of precedence .

Logical expressions can be stored as LOGICAL variables.

IF statements can be nested within one of the flow control constructs but not vice-versa.

Unlike flow control constructs, an IF statement can not be named.

For most purposes, an IF construct is preferred to an IF statement, even in simple cases. For example,

IF(x<0.0)THEN
x=-x
ENDIF

though less concise, scans more easily. The IF statement may, however, be preferred for use with the statements STOP, RETURN, EXIT and CYCLE.

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited