System symbolic constants
From CometWiki
(New page: == System Symbolic Constants == As of Build 278, Comet includes four system symbolic constants. Like system variables, these symbolic constants are available to be used in an Internet Ba...)
Newer edit →
Revision as of 09:54, 31 May 2009
Contents |
System Symbolic Constants
As of Build 278, Comet includes four system symbolic constants. Like system variables, these symbolic constants are available to be used in an Internet Basic program without being defined or set. The four system symbolic constants are:
TRUE FALSE DECPASS EXEPASS
TRUE
For every source program and usefile that is compiled, Comet sets the following values for the TRUE and FALSE system symbolic constants: Symbolic constant Value TRUE 1 FALSE 0
This is the equivalent of an Internet Basic program using the following directives:
SET TRUE = 1 SET FALSE = 0
Note, however, that these SET directives are not required in an Internet Basic 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"):
remove the SET TRUE and SET FALSE directives from your code and rely on the automatic definitions, or
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
FALSE
For every source program and usefile that is compiled, Comet sets the following values for the TRUE and FALSE system symbolic constants: Symbolic constant Value TRUE 1 FALSE 0
This is the equivalent of an Internet Basic program using the following directives:
SET TRUE = 1 SET FALSE = 0
Note, however, that these SET directives are not required in an Internet Basic 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"):
remove the SET TRUE and SET FALSE directives from your code and rely on the automatic definitions, or
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
Comet sets the DECPASS and EXEPASS system symbolic constants as follows: During the Internet Basic compiler's declarative pass Symbolic constant Value DECPASS 1 EXEPASS 0
During the Internet Basic compiler's executable pass
Symbolic constant Value
DECPASS 0
EXEPASS 1
In other words, while Internet Basic is compiling statements in the declarative section of the program, these values are set one way, and when Internet Basic 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 symbolic constants involves conditional compilation of statements in a usefile. By using the .IF and .ENDIF directives in combination with DECPASS and EXEPASS, you can 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.
EXEPASS
Comet sets the DECPASS and EXEPASS system symbolic constants as follows: During the Internet Basic compiler's declarative pass Symbolic constant Value DECPASS 1 EXEPASS 0
During the Internet Basic compiler's executable pass
Symbolic constant Value
DECPASS 0
EXEPASS 1
In other words, while Internet Basic is compiling statements in the declarative section of the program, these values are set one way, and when Internet Basic 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 symbolic constants involves conditional compilation of statements in a usefile. By using the .IF and .ENDIF directives in combination with DECPASS and EXEPASS, you can 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.