System symbolic constants

From CometWiki

(Difference between revisions)
Jump to: navigation, search
(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...)
 
Line 1: Line 1:
-
 
== System Symbolic Constants ==
== System Symbolic Constants ==
Line 12: Line 11:
   
   
For every source program and usefile that is compiled, Comet sets the following values for the TRUE and FALSE system symbolic constants:  
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 
 
 +
{| Border=1
 +
|-
 +
|Symbolic constant 
 +
|Value 
 +
|-
 +
|TRUE 
 +
|1 
 +
|-
 +
|FALSE 
 +
|0 
 +
|-
 +
|}
This is the equivalent of an Internet Basic program using the following directives:  
This is the equivalent of an Internet Basic program using the following directives:  
-
SET TRUE = 1
+
SET TRUE = 1
-
SET FALSE = 0
+
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.  
+
'''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"):  
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  
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 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 TRUE
-
UNSET FALSE
+
UNSET FALSE
-
 
+
== FALSE ==
== FALSE ==
   
   
-
For every source program and usefile that is compiled, Comet sets the following values for the TRUE and FALSE system symbolic constants:  
+
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 
+
 +
{| Border=1
 +
|-
 +
|Symbolic constant 
 +
|Value 
 +
|-
 +
|TRUE 
 +
|1 
 +
|-
 +
|FALSE 
 +
|0 
 +
|-
 +
|}
This is the equivalent of an Internet Basic program using the following directives:  
This is the equivalent of an Internet Basic program using the following directives:  
-
SET TRUE = 1
+
SET TRUE = 1  
-
SET FALSE = 0
+
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.  
+
'''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"):  
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"):  
Line 51: Line 68:
remove the SET TRUE and SET FALSE directives from your code and rely on the automatic definitions, or  
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 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 TRUE
-
UNSET FALSE
+
UNSET FALSE
-
 
+
== DECPASS ==
== DECPASS ==
Line 59: Line 75:
Comet sets the DECPASS and EXEPASS system symbolic constants as follows:  
Comet sets the DECPASS and EXEPASS system symbolic constants as follows:  
During the Internet Basic compiler's declarative pass   
During the Internet Basic compiler's declarative pass   
-
Symbolic constant  Value 
 
-
DECPASS  1 
 
-
EXEPASS  0 
 
 +
{| Border=1
 +
|-
 +
|Symbolic constant 
 +
|Value 
 +
|-
 +
|DECPASS 
 +
|1 
 +
|-
 +
|EXEPASS 
 +
|0 
 +
|-
 +
|}
During the Internet Basic compiler's executable pass   
During the Internet Basic compiler's executable pass   
-
Symbolic constant  Value 
 
-
DECPASS  0 
 
-
EXEPASS  1 
 
 +
{| Border=1
 +
|-
 +
|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.  
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.  
Line 76: Line 110:
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:  
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
+
.IF DECPASS
-
(declarative statements)
+
(declarative statements)
-
.ENDIF
+
.ENDIF
-
.IF EXEPASS
+
.IF EXEPASS
-
(executable statements)
+
(executable statements)
-
.ENDIF
+
.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.  
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.  
Line 92: Line 126:
Comet sets the DECPASS and EXEPASS system symbolic constants as follows:  
Comet sets the DECPASS and EXEPASS system symbolic constants as follows:  
During the Internet Basic compiler's declarative pass   
During the Internet Basic compiler's declarative pass   
-
Symbolic constant  Value   
+
 
-
DECPASS  1   
+
{| Border=1
-
EXEPASS  0   
+
|-
 +
|Symbolic constant   
 +
|Value
 +
|-  
 +
|DECPASS   
 +
|1
 +
|-  
 +
|EXEPASS   
 +
|0
 +
|-
 +
|}  
During the Internet Basic compiler's executable pass   
During the Internet Basic compiler's executable pass   
-
Symbolic constant  Value 
 
-
DECPASS  0 
 
-
EXEPASS  1 
 
 +
{| Border=1
 +
|-
 +
|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.  
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.  
Line 109: Line 162:
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:  
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
+
.IF DECPASS
-
(declarative statements)
+
(declarative statements)
-
.ENDIF
+
.ENDIF
-
.IF EXEPASS
+
.IF EXEPASS
-
(executable statements)
+
(executable statements)
-
.ENDIF
+
.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.  
+
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.
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.

Latest revision as of 10:08, 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.