pTAL Reference Manual (H06.03+)

Statements
HP pTAL Reference Manual523746-005
12-8
Examples
Examples
Assignment statements can assign character strings but not constant lists, so in
Example 12-5 on page 12-8, the three assignment statements together store the same
value as the one constant list in the declaration.
In Example 12-6
on page 12-8, the first assignment statement (which contains
assignment expression
s) is equivalent to the three separate assignments that follow it.
Example 12-4. Assignment Statements
INT array[0:2]; ! Array
INT .ptr; ! Simple pointer
REAL real_var; ! REAL variable
FIXED fixed_var; ! FIXED variable
array[2] := 255; ! Assign a value to array[2]
@ptr := @array[1]; ! Assign address of array[1]
! to ptr
ptr := array[2]; ! Assign value of array[2]
! to array[1], to which ptr
! points
real_var := 36.6E-3; ! Assign a REAL value to a
! REAL variable
fixed_var := $FIX (real_var); ! Convert a REAL value to FIXED
! and assign to a FIXED variable
Example 12-5. Assignment Statements Equivalent to a Constant List
INT .b[0:2] := ["ABCDEF"]; ! Declare and initialize
! with constant list
b[0] := ["AB"];
b[1] := ["CD"];
b[2] := ["EF"];
Example 12-6. Assignment Statement With Assignment Expressions
INT int1;
INT int2;
INT int3;
INT var := 16;
int1 := int2 := int3 := var; ! Assignment that contains
! assignment expressions
int1 := var; ! Separate assignments
int2 := var;
int3 := var;