pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

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
Assignment statements can assign character strings but not constant lists, so in Example 144
(page 204), the three assignment statements together store the same value as the one constant list
in the declaration.
Example 144 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"];
In Example 145 (page 204), the first assignment statement (which contains assignment expressions)
is equivalent to the three separate assignments that follow it.
Example 145 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;
Bit-Deposit Assignment
The bit deposit form of the assignment statement lets you assign a value to an individual bit or to
a group of sequential bits.
variable
is the identifier of a STRING or INT variable, but not an UNSIGNED(1-16) variable. variable
can be the identifier of a simple variable, array element, or simple pointer (inside or outside
a structure).
left-bit
is an INT constant that specifies the leftmost bit of the bit deposit field.
For STRING variables, specify a bit number in the range 8 through 15. Bit 8 is the leftmost bit
in a STRING variable; bit 15 is the rightmost bit.
204 Statements