IBM extension

Assertion directives

An assertion directive is an alternative to a macro definition, used to define the computer or system the compiled program will run on. Assertions are usually predefined, but you can define them with the #assert preprocessor directive.

Read syntax diagramSkip visual syntax diagram#assert directive syntax
 
>>-#--assert--predicate--(--answer--)--------------------------><
 

The predicate represents the assertion entity you are defining. The answer represents a value you are assigning to the assertion. You can make several assertions using the same predicate and different answers. All the answers for any given predicate are simultaneously true. For example, the following directives create assertions regarding font properties:

#assert font(arial)
#assert font(blue)

Once an assertion has been defined, the assertion predicate can be used in conditional directives to test the current system. The following directive tests whether arial or blue is asserted for font:

#if #font(arial) || #font(blue)

You can test whether any answer is asserted for a predicate by omitting the answer in the conditional:

#if #font

Assertions can be cancelled with the #unassert directive. If you use the same syntax as the #assert directive, the directive cancels only the answer you specify. For example, the following directive cancels the arial answer for the font predicate:

#unassert font(arial)

An entire predicate is cancelled by omitting the answer from the #unassert directive. The following directive cancels the font directive altogether:

#unassert font

Related information