pTAL Reference Manual (H06.08+)
Statements
HP pTAL Reference Manual—523746-006
12-6
Pointer Assignment
When an INT variable is assigned to a STRING variable, the upper 8 bits of the
INT variable are not retained in any way in the STRING variable. Thus, the
comparison of i1 to i2 in the final statement of the following code fails
because i2 still holds the full 16 bits that were assigned to it at the beginning
of the code, but i1 holds only the lower 8 bits. The upper 8 bits of I1 are not
transferred to s in the assignment statement s := i1.
INT i1 := %HFFFF,
i2;
STRING s;
i2 := i1; ! Copy i1 to i2
s := i1; ! Assign 16-bit INT to 8-bit STRING
i1 := s; ! Assign 8-bit STRING to 16-bit INT
IF i1 = i2 THEN; ! i1 (%HFF) is not equal to i2 (%HFFFF)
°
UNSIGNED(17-31) variables are syntactically and semantically equivalent to
INT(32) variables. Thus, UNSIGNED(17-31) variables are valid anywhere
INT(32) variables are valid:
INT(32) i;
UNSIGNED(31) u;
INT j;
i := u; ! OK: No bits are lost in assignment
u := i; ! WARNING: Most significant bit of i could
! be lost
u := j; ! ERROR: INT and UNSIGNED(17-31) are not
! assignment-compatible
Topics:
•
Pointer Assignment on page 12-6
•
Assigning Numbers to FIXED Variables on page 12-7
•
Assigning Character Strings on page 12-7
•
Examples on page 12-8
Pointer Assignment
The result of applying an @ operator to a variable or pointer is an address whose data
type is one of the pTAL address types.
In an assignment statement, one of the following must be true:
•
Both operands are the same address type.
•
Neither operand is an address type.










