Please enable JavaScript to view this site.

A-Shell Development History

Navigation: Version 5.1/6.0, builds 1100-1271 > 1125 – 27 Sep 08

Conditional Compilation Statements

Scroll Prev Top Next More

The following conditional compilation statements which are supported by compiler modes /RC and /X:1 or higher.

Symbol

Description

++IFDEF <symbol>

Compiles the following statements if the specified symbol is defined using a DEFINE statement, or is a structure defined with DEFSTRUCT, or is defined on the compiler command line with a /C:symbol=value clause (see below).

++IFNDEF <symbol>

The logical reverse of ++IFDEF <symbol>.

++IF <constant expression>

See below.

++ELSE

Compiles the subsequent code only if none of the prior ++IF and ++ELIF clauses were true.

++ELIF <constant expression>

Is similar to ++IF <constant expression> except that it is used in an IF..ELIF..ELIF..ELSE..ENDIF construction.

++ENDIF

Marks the end of the conditional construct.

 

Example1

++IFDEF GUI

PROGRAM MYPROG,1.0G(100)

<source code implementing GUI version here>

++ELSE

PROGRAM MYPROG,1.0(100)

<source code implementing text version here>

++ENDIF

 

The above illustrates one way to use conditional compilation to conditionally create either a GUI or text version of your RUN file, starting from the same source file. Previously you could only do the same thing with runtime conditions (which may still be a better option in most cases), but in some cases, you may prefer to have two separate versions of the RUN (perhaps to keep the size down, or to simplify runtime debugging.) Note that the symbol GUI would have had to have been defined somewhere prior to the compiler seeing these statements (see below for how to define symbols on the command line).

Also note that we used two different versions of the PROGRAM statement in the above example, so that you can easily tell which RUN version you have by displaying it with DIR/V.

Example2

++IF APPVER = 1

++MESSAGE Compiling Version 1

++INCLUDE ver1.bsi

++ELIF APPVER = 2

++MESSAGE Compiling Version 2

++INCLUDE ver2.bsi

++ELSE

++ERROR No APPVER defined!

++ENDIF

 

This illustrates the IF/ELIF/ELSE/ENDIF construct, used to select which ++include file to use based on the defined APPVER. See below for an explanation of the ++MESSAGE and ++ERROR statements.

Example3

++IFDEF SBX

++PRAGMA SBX

<retrieve parameters, SBX setup, etc.>

++ENDIF

 

This illustrates a simple way to allow a single source file to be compiled as either an SBX or a RUN file. (The SBX symbol would need to be defined on the compiler command line, e.g. COMPIL MYPROG/X:2/C:SBX=1)