Const Statement
Language Items List
Definition:
Allows you to declare a meaningful symbolic name to use in place of a literal
value.
Syntax:
[Global]Const constantname = expression [,constantname = expression] ...
Syntax Description
Global Optional word that can be placed before Const. This word has no significance
in Phoenix other than to provide compatibility with other versions of BASIC.
constantname Constant's name.
expression Expression assigned to the constant. It can include string or numeric
literals, other constants, or an arithmetic or logical operator. The exception is
exponentiation (^), which causes a program exception to be thrown. String
concatenation, variables, user-defined functions, and intrinsic Phoenix functions are not
allowed in expressions assigned to constants.
Note: Constants can make your programs more readable and self-documenting, making
your programs easier to change. Constants cannot be inadvertently changed while
your program is running. Constants are commonly typed using all capitals for
quick identification in a program listing.
Details:
Assigning a constant allows you to reduce the number of changes you must make
to a value that is used in several places throughout a program. If you assign
your constant correctly, you need only modify the value in one place if changes
are necessary.
Caution: Constants must be defined before they are used or a program exception is
thrown during execution.
To indicate the constant's data type, you can include a type-declaration
character at the end of constantname. This character, however, is not included in the name.
If you do not include a type-declaration character in the name, Phoenix
assigns a data type automatically. If you assign a string, the constant is always a
string. If the constant is assigned a Numeric expression, first it is evaluated,
then based on the evaluation, the constant is assigned the simplest possible
data type.
To make a global constant, the Const statement would have to appear as a
member of a Globals object or an object that derives from Globals.
Constants are valid anywhere you would use an expression.
Note: Place Global constant definitions in one module only, to help prevent
unresolvable cross-module dependencies.