Declaring constants
Description
Any PowerScript variable declaration of a standard datatype that can
be assigned an initial value can be a constant instead of a variable. To
make it a constant, include the keyword CONSTANT in the declaration and
assign it an initial value.
Syntax
|
1 |
CONSTANT { access } datatype constname = value |
The following table shows the parameters used to declare
constants.
|
Parameter |
Description |
|---|---|
|
CONSTANT |
Declares a constant instead of a variable. The |
|
access (optional) |
(For instance variables only) Keywords specifying the |
|
datatype |
A standard datatype for the constant. For decimals, For |
|
constname |
The name of the constant (must be a valid PowerScript |
|
value |
A literal or expression of the appropriate datatype |
Usage
When declaring a constant, an initial value is required. Otherwise,
a compiler error occurs. Assigning a value to a constant after it is
declared (that is, redefining a constant in a descendant object) also
causes a compiler error.
Examples
Although PowerScript is not case sensitive, these examples of local
constants use a convention of capitalizing constant names:
|
1 2 |
constant string LS_HOMECITY = "Boston" constant real LR_PI = 3.14159265 |