Silverfrost Logo About Us | Contact Us
 

Silverfrost Conditional compilation

FTN95 provides conditional compilation by means of the SPECIAL PARAMETER statement together with the /SPARAM and /VPARAM compile-time options and the CIF, CELSE and CENDIF statements.

 

SPECIAL PARAMETER statement

The specification statement

SPECIAL PARAMETER <name>

defines <name> to be of type integer. <name> must not appear in a type statement and is local to the program unit in which the SPECIAL PARAMETER statement appears. The value represented by <name> is set by means of the /SPARAM or /VPARAM compile-time option as follows:

/SPARAM <integer>

where <integer> is the required value.

Any number of SPECIAL PARAMETER names are allowed per program unit but they are all assigned the same value when used with /SPARAM. The alternative is:

/VPARAM <name> <integer>

which allows individual values to be assigned by name rather than assigning one value to all. A value assigned by /VPARAM over-rides a value assigned by /SPARAM.

 

CIF, CELSE and CENDIF

CIF, CELSE and CENDIF are used to select the statements in a program unit that are to be used during a particular compilation. Their general forms are:

CIF (<name> <op> <constant>) THEN
 . . .
CELSE
 . . .
CENDIF

where <name> is a SPECIAL PARAMETER, <op> is one of the arithmetic relational operators (.EQ.,.LT., etc. or their equivalents ==, < etc.) and <constant> is an integer constant. In fixed format, CIF etc. begin in column 7 or after.

CIF and CENDIF must appear in pairs: their appearance constitutes a CIF-block.

The actual value assigned to the special parameter <name> is compared with the integer constant <constant>. If the two agree, the statements following CIF are compiled until a CELSE or CENDIF statement is found.

If the two disagree, statements are ignored until a CELSE or CENDIF statement is encountered. Such statements are denoted by a back-slash character in the listing file.

Once CENDIF is encountered, the CIF-block is complete. CELSE causes the reverse effect to that specified by the preceding CIF statement.

CIF..CENDIF blocks can be nested and CELSEIF may be used to replace the sequence CELSE, CIF,.....CENDIF as in the Fortran IF construct.

SPECIAL PARAMETERS can be assigned using /SPARAM, /VPARAM or by using a standard Fortran PARAMETER statement. Values that are not set, default to zero. If /SPARAM and /VPARAM are not used, then /FPP must be included in the compiler command line in order to invoke the preprocessor (note that /FPP is included in /CLR).

As a special case, the form

CIF (<name>) THEN
. . .

can be used where <name> is assigned to 1 (unity, representing TRUE) or to zero (representing FALSE).

The additional features described in Conditonal compilation and detecting .NET at runtime can also be used on a Win32 platform.

 

 

Copyright © 1999-2017 Silverfrost Limited