10.4 Compile Time Constants and Variables


10.4 Compile Time Constants and Variables

Just as the run-time language supports constants and variables, so does the compile time language. You declare compile time constants in the const section, the same as for the run-time language. You declare compile time variables in the val section. Objects you declare in the val section are constants as far as the runtime language is concerned, but remember that you can change the value of an object you declare in the val section throughout the source file. Hence the term "compile time variable." See Chapter 4 in this text for more details.

The CTL assignment statement ("?") computes the value of the constant expression to the right of the assignment operator (":=") and stores the result into the val object name appearing immediately to the left of the assignment operator.[1] This example code may appear anywhere in your HLA source file, not just in the val section of the program.

      ?ConstToPrint := 25;      #print( "ConstToPrint = ", ConstToPrint )      ?ConstToPrint := ConstToPrint + 5;      #print( "Now ConstToPrint = ", ConstToPrint ) 

[1]If the identifier to the left of the assignment operator is undefined, HLA will automatically declare this object at the current scope level.




The Art of Assembly Language
The Art of Assembly Language
ISBN: 1593272073
EAN: 2147483647
Year: 2005
Pages: 246
Authors: Randall Hyde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net