Caché Basic Reference
Declares constants for use in place of literal values.
Const constname = expression
statement syntax has these parts:
||Name of the constant; follows standard variable-naming conventions.
||Literal or any combination that includes all arithmetic or logical operators except Is.
To combine several constant declarations on the same line, separate each constant assignment with a comma.
You cannot use variables, user-defined functions, or intrinsic Caché Basic functions (such as Chr
) in constant declarations. By definition, they cannot be constants. Constants declared in a Sub
procedure are local to that procedure. A constant declared outside a procedure is defined throughout the script in which it is declared. You can use constants anywhere you can use an expression.
The following code illustrates the use of the Const
Const MyVar = 459
' Declare multiple constants on same line.
Const MyStr = "Hello", MyNumber = 3.4567
Constants can make your scripts self-documenting and easy to modify. Unlike variables, constants cannot be inadvertently changed while your script is running.