Syntax of a variable declaration
Simple syntax
In its simplest form, a PowerScript variable declaration requires
only two parts: the datatype and the variable name. For example:
|
1 |
datatype <span>variablename</span> |
Full syntax
The full syntax allows you to specify access and an initial
value. Arrays and some datatypes, such as blobs and decimals, accept
additional information:
|
1 |
{ <span>access</span> } <span>datatype</span> { <span>{ size }</span> } { <span>{ precision }</span> } <span>variablename</span> { = <span>value</span> }<br> {, <span>variablename2</span> { = <span>value2</span> } } |
|
Parameter |
Description |
|---|---|
|
access |
(For instance variables only) Keywords |
|
datatype |
The datatype of the variable. You can For blobs and decimals, |
|
{ size } |
(For blobs only) A number, enclosed in If you enter a size that exceeds the declared length in a |
|
{ precision } |
(For decimals only) A number, enclosed |
|
variablename |
The name of the variable (must be a valid You can define additional variables with the same datatype |
|
value |
A literal or expression of the appropriate Blobs cannot be initialized with a value. For information, see “Initial values for variables”. |
Examples
Declaring instance variables
|
1 |
integer ii_total = 100 // Total shares |
|
1 |
date id_date // Date shares were bought |
Declaring a global variable
|
1 |
string gs_name |
Declaring shared variables
|
1 |
time st_process_start |
|
1 |
string ss_process_name |
Declaring local variables
|
1 |
string ls_city = "Boston" |
|
1 |
integer li_count |
Declaring blobs
This statement declares ib_Emp_Picture a
blob with an initial length of zero. The length is adjusted when
data is assigned to it:
|
1 |
blob ib_Emp_Picture |
This statement declares ib_Emp_Picture a
blob with a fixed length of 100 bytes:
|
1 |
blob{100} ib_Emp_Picture |
Declaring decimals
These statements declare shared variables sc_Amount and sc_dollars_accumulated as
decimal numbers with two digits after the decimal point:
|
1 |
decimal{2} sc_Amount |
|
1 |
decimal{2} sc_dollars_accumulated |
This statement declares lc_Rate1 and lc_Rate2 as
decimal numbers with four digits after the decimal point:
|
1 |
dec{4} lc_Rate1, lc_Rate2 |
This statement declares lc_Balance as
a decimal with zero digits after the decimal point:
|
1 |
decimal{0} lc_Balance |
This statement does not specify the number of decimal places
for lc_Result. After the product of lc_Op1 and lc_Op2 is
assigned to it, lc_Result has four decimal
places:
|
1 |
dec lc_Result |
|
1 |
dec{2} lc_Op1, lc_Op2 |
|
1 |
lc_Result = lc_Op1 * lc_Op2 |