![]() ![]() |
|
EQUATEEQUATE is used to declare a symbol equivalent to a literal, variable or simple expression.
COMMAND SYNTAXEQU{ATE} symbol TO expression
SYNTAX ELEMENTSsymbol is the name of the symbol to use. Can be any name that would be valid for
a variable.
NOTESSensible use of EQUATEd symbols can make your program easier to maintain, easier to read, and more efficient. Efficiency can be enhanced because the address of an EQUATEd value is computed during compilation and is substituted for each occurrence of the symbol name. Unlike the address of a variable, which has to be computed for each access during run time, the address of a symbol is always known. This means that the processing overhead involved in accessing a particular value can be significantly reduced. See the example for a more detailed explanation of the other benefits. Readability can be enhanced by referring to say, QTY rather than INV_LINE(4). You would simply "EQUATE QTY TO INV_LINE(4)" at an early stage in the program. This can also help with maintenance of the program, particularly in situations where record layouts might change. For example, if the quantity field moves to INV_LINE(6), you will only have to change one line in your program.
EXAMPLE
|