A VAR section declares variables and associates each variable
with an identifier, a type, and optionally an initial value.
Syntax:
VAR
{{variable-identifier},... : [[attribute-list]] type-denoter
[[ {:= | VALUE} initial-state-specifier]]};...
The 'variable-identifier' is the identifier of the variable
being declared.
The 'attribute-list' is one or more optional identifiers that
provide additional information about the variable.
The 'type-denoter' is any legal Pascal type syntax.
The 'initial-state-specifier' is any constant expression that is
assignment compatible with the variable identifier. The
variable is initialized to this expression. See the "HP Pascal
Language Reference Manual" for the rules that apply to the use
of initial-state specifiers on variables.
You can use either the assignment operator (:=) or the reserved
word VALUE. However, if you require portable code, you should
use VALUE.
Example:
TYPE
Hours_worked = ARRAY [1..10] OF INTEGER;
VAR
Answer, Rumor : Boolean;
Temp : INTEGER VALUE 60;
Grade : 'A'..'D';
Weekly_hours : Hours_worked VALUE [1..3 : 7; OTHERWISE 5];
This VAR section declares five variables. The variables
'Answer' and 'Rumor' are both Boolean variables; 'Temp' is an
integer variable initialized with the value 60; 'Grade' is of a
character subrange type consisting of the characters
'A','B','C', and 'D'; 'Weekly_hours' is declared to be of the
user-defined array type 'Hours_worked' and is initialized with a
constructor of integers.