Home   Comet Tips

Comet Tip


 

  November 17, 2000  

 

Using the System Symbolic Constants

 

As of Comet98 and Comet2000 Build 278, Comet includes four system symbolic constants. Like system variables, these symbolic constants are available to be used in an MTB program without being defined or set. The four system symbolic constants are:

 

            TRUE

            FALSE

            DECPASS

            EXEPASS

 

Here is an explanation of these values.

 

TRUE and FALSE

 

For every source program and usefile that is compiled, Comet sets these values as follows:

 

            Symbolic constant         Value

            TRUE                          1

            FALSE                        0

 

This is the equivalent of an MTB program using the following directives:

 

            SET TRUE = 1

            SET FALSE = 0

 

Note, however, that these SET directives are not required in an MTB program. Comet defines the TRUE and FALSE symbolic constants automatically.

 

If you have an existing source program (or usefile) that defines TRUE or FALSE as symbolic constants, you will need to take one of the following steps to avoid getting a compiler error (i.e., error 04 –  “variable has been previously defined”):

 

1.      remove the SET TRUE and SET FALSE directives from your code and rely on the automatic definitions, or

2.      unset the system symbolic constants at the beginning of your source program/usefile, and rely on your program’s SET TRUE and SET FALSE directives, as follows:

 

UNSET TRUE

UNSET FALSE

 

DECPASS and EXEPASS

 

Comet sets these system symbolic constants as follows:

 

            During the MTB compiler’s declarative pass:

 

            Symbolic constant         Value

            DECPASS                   1

            EXEPASS                   0

 

            During the MTB compiler’s executable pass:

 

            Symbolic constant         Value

            DECPASS                   0

            EXEPASS                   1

 

In other words, while MTB is compiling statements in the declarative section of the program, these values are set one way, and when MTB is compiling statements in the executable section of the program, these values are set another way.

 

(We realize that it’s semantically impossible to have “variable constants,” but we still think that “symbolic constant” is the best way to describe these terms.)

 

The most obvious application of these new symbolic constants involves conditional compilation of statements in a usefile. By using the .IF and .ENDIF statements in combination with DECPASS and EXEPASS, you can now include both declarative and executable code in a single usefile. Here’s a code outline that shows how this works:

 

.IF DECPASS

(declarative statements)

.ENDIF

 

.IF EXEPASS

(executable statements)

.ENDIF

 

During the compiler’s declarative pass, the .IF DECPASS directive is evaluated as true (because DECASS equals 1). During this pass, the .IF EXEPASS directive is evaluated as false (because EXEPASS equals 0). Result: During this pass, the declarative statements are compiled, but the executable ones are not.

 

However, during the executable pass, things are reversed. The .IF DECPASS directive becomes false, and the .IF EXEPASS directive becomes true. Result: During this pass, the executable statements are compiled, but the declarative ones are not.

 

Please note that these system symbolic constants are now implemented in the MTB Windows Development Tools and that you may have to change your source programs and/or usefiles to accommodate these new features.