Conditional Compile (Advanced)

Top  Previous  Next

The command word "condition" is used to conditionally compile sections of code. "condition" must be followed by an expression that evaluates to true or false. If this expression is false then the following code is treated as a comment. This commented-out code is terminated by a second "condition" that evaluates to true. "condition" works everywhere except in comments and strings. It can be used to change declarations as well as executable code. For example:

 

        def     Debug = true;

 

        condition Debug;

        int     X;

        condition not Debug;

        real    X;

        condition true;

 

        begin

        cond not Debug;

        X:= 3.0;

        cond Debug;

        X:= 3;

        cond true;

      . . .

"Condition" is intended for commenting out code--not for comments in general. Even though the condition is false, the code that follows is not completely ignored. The compiler is scanning for a lowercase word that starts: "con". Also, some minimal syntax checking is done. For instance, a dollar sign ($) must still be followed by a hex digit, otherwise an error is flagged.