Encyclopaedia Index

IF .... THEN .... ELSE .... ENDIF

The IF..THEN..ELSE construct is almost identical to the FORTRAN feature, both in syntax and effect.

The only differences are the limitations on the form of the <logical expression> (see below) and that the construct ELSEIF is not supported.

IF constructs can be nested to a maximum depth of 20 and inter- leaved freely with DO loops and other "flow-control" features.

The syntax of the block IF is:

IF <logical expression> THEN + <PIL statements 1> ELSE + <PIL statements 2> ENDIF

For example: IF(NX.GT.1) THEN + SOLVE(U1) -----> PIL statement ELSE + SOLVE(V1) -----> PIL statement ENDIF

The <logical expression> has a syntax and capability very similar to the corresponding FORTRAN construct, with the following differences:

  1. There is no precedence on the operators .AND. .OR. and .NOT.; it is therefore recommended that brackets are used to remove potential ambiguities.
  2. A .NOT. must not immediately follow an .AND. or .OR. but must be preceded by a bracket. Eg (CARTES.AND..NOT.NONORT) is illegal and must be written as (CARTES.AND.(.NOT.NONORT))
  3. String constants are not enclosed by quotes; but string variables should be enclosed by colons

IFs can be nested to a maximum depth of 20.


wbs