EQUATE, EQU |
![]() ![]() ![]() |
The EQUATE statement defines a symbolic name to represent a constant or reference to a matrix element.
Format
EQUATE name TO value EQUATE name TO variable EQUATE name TO matrix(index1 {, index2) EQUATE name TO CHAR(seq)
where
The first form of the EQUATE statement creates a symbolic name that can be used in place of the constant value. The EQUATE statement can be used to eliminate constants for state variables, etc from the main body of a program. Subsequent changes to the value thus only require a single amendment and recompilation of all programs using name. A similar function can be performed using the $DEFINE compiler directive.
The EQUATE statement can also be used to give names to specific elements of a matrix. Declaration and dimensionality of the matrix are only checked when a reference to name is encountered during program compilation. The matrix index values index1 and index2 must be numbers. Reference to the zero element of a two dimensional matrix must include both index values. The $DEFINE compiler directive cannot be used to define names for matrix elements.
The fourth form allows EQUATE to be used to assign names to specific (usually non-printing) characters.
Multiple tokens may be equated on a single line by separating each definition by a comma. For example:
EQUATE LOW TO 12, HIGH TO 20
Examples
EQUATE ADDRESS TO 1 EQUATE TEL.NO TO 2 ... READ REC FROM DATA.FILE, ID THEN PRINT "Address: " : REC<ADDRESS> PRINT "Telephone: " : REC<TEL.NO> END
The above program fragment attaches name to two fields of a data record and then uses these when the data is extracted for printing.
EQUATE ADDRESS TO REC(1) EQUATE TEL.NO TO REC(2) DIM REC(10) ... MATREAD REC FROM DATA.FILE, ID THEN PRINT "Address: " : ADDRESS PRINT "Telephone: " : TEL.NO END
This program fragment achieves the same as the previous example but uses the MATREAD statement to separate the fields of the record read from the file into the elements of matrix REC. The names defined in the EQUATE statements are then used to reference elements of this matrix
See also: |