Caché MultiValue Basic Reference
EQUATE
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   
Search:    

Replaces a symbol with a value at compile time.
Synopsis
EQUATE symbol TO expression [, ...]
EQU symbol TO expression [, ...]

EQUATE symbol LITERALLY str [, ...]
EQU symbol LIT str [, ...]
Arguments
symbol The placeholder symbol to be replaced, specified as one or more characters. The first character must be a letter or percent sign (%). Subsequent characters may be letters, numbers, percent sign (%), underscore (_), or dollar sign ($). The final character may not be an underscore.
expression The value used to replace all instances of symbol at compile time. Any valid Caché MVBasic expression.
str The string used to replace all instances of symbol at compile time. Specified as a quoted string.
Description
EQUATE replaces every instance of symbol in the program with the specified expression or variable. EQUATE performs this substitution at compile time. Therefore, the value replaced is not affected by program execution. EQUATE can be used to replace executable statements in the program. Variables perform substitutions during program execution and cannot be used to modify the program's executable code.
You can specify multiple symbol TO expression and symbol LITERALLY str clauses in any combination as a comma-separated list. You can insert line breaks as needed following a comma separator.
EQUATE treats a sequence of words separated by –> as a single entity. For example:
EQUATE vin TO car(7)
AutoCheck->vin = vin
returns AutoCheck->vin = car(7).
The EQUATE keyword can be abbreviated as EQU. The LITERALLY keyword can be abbreviated as LIT.
Examples
The following example replaces at compile time every instance of the symbol addlength with the expression BYTELEN(x)+20 or LEN(x)+10, depending on the setting of the Unicode variable:
IF Unicode=1
  THEN EQUATE addlength TO BYTELEN(x)+20
  ELSE EQUATE addlength TO LEN(x)+10 
The following example replaces at compile time every instance of the symbol letters with the contents of the variable alpha:
EQUATE letters LITERALLY "alpha"
BEGIN CASE
  CASE lang=English
     alpha="abcdefghijklmnopqrstuvwxyz"
  CASE lang=Greek
     alpha="&agr;&bgr;&ggr;&dgr;ε&zgr;&eegr;&thgr;&igr;&kgr;&lgr;&mgr;&ngr;&ogr;&pgr;&rgr;&sfgr;&sgr;&tgr;&ugr;&phgr;&khgr;&psgr;&ohgr;"
END CASE
See Also