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 { <span>access </span>} <span>datatype constname</span> = <span>value</span> |
The following table shows the parameters used to declare constants.
|
Parameter |
Description |
|---|---|
|
CONSTANT |
Declares a constant instead of a variable. |
|
access |
(For instance variables only) Keywords |
|
datatype |
A standard datatype for the constant. For information about PowerBuilder datatypes, |
|
constname |
The name of the constant (must be a valid |
|
value |
A literal or expression of the appropriate |
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 |
constant string LS_HOMECITY = "Boston" |
|
1 |
constant real LR_PI = 3.14159265 |