pTAL Reference Manual (H06.03+)

Statements
HP pTAL Reference Manual523746-005
12-5
Assignment
expression
is either:
An arithmetic expression of the same data type as variable
A conditional expression, which always has an INT result
expression can be a bit extraction value or an identifier prefixed with @ (the
address of a variable). expression cannot be a constant list.
In general, the data types of variable and expression must match. To
convert the data type of expression to match the data type of variable, use a
type-transfer routine, described in Section 15, Built-In Routines.
The following rules apply to assignment statements:
The data type of the expression on the right side of an assignment statement must
be compatible with the data type of the destination on the left side of the
assignment statement.
You cannot store a value into the implicit pointer of an indirect array or indirect
structure.
You cannot store a value into the implicit pointer of an equivalenced variable that
references the data of an indirect array or indirect structure.
Do not depend on whether the left side or the right side of an assignment
statement is evaluated first.
Address types must match.
pTAL disallows all assignments of unlike data types except the following:
°
STRING and UNSIGNED(1-16) variables are syntactically and semantically
equivalent to INT variables. Thus, STRING and UNSIGNED(1-16) variables
are valid anywhere an INT variable is valid.
An UNSIGNED(1-16) variable or one-byte STRING value that is used as an
INT value is left-filled with binary zeros. Conversely, the high-order bits of an
INT value are lost if the value is stored in an UNSIGNED variable that is less
than 16 bits, or to a one-byte STRING variable, as shown in the following
examples:
INT i := 3;
STRING s;
UNSIGNED(12) u1;
UNSIGNED(24) u2;
s := i + 1; ! OK: Assignment of INT to STRING
i := s + %H20; ! OK: Assignment of STRING to INT
u1 := i + s; ! OK: INT + STRING
u2 := i; ! ERROR: INT and UNSIGNED(17-31) are not
! assignment-compatible