pTAL Reference Manual (H06.03+)
Equivalenced Variables
HP pTAL Reference Manual—523746-005
11-12
Equivalenced Simple Pointers
Using Equivalenced Simple Pointers
If the previous variable is a pointer, an indirect array, or an indirect structure, the
previous pointer and the new pointer must both contain either:
•
A standard byte address
•
A standard word address
•
An extended address
Otherwise, the pointers will point to different locations, even if they both contain the
same value. That is, a standard STRING or extended pointer normally points to a byte
address, and a standard pointer of any other data type normally points to a word
address.
You can equivalence standard pointers to indirect arrays and indirect structures, but
you can only read the value of the pointer. You cannot store an address into the
pointer. You can, however, read or write the data to which the pointer points.
You can equivalence extended pointers to extended arrays and extended structures,
but you can only read the value of the pointer. You cannot store an address into the
pointer. You can, however, read or write the data to which the pointer points.
You can equivalence a standard pointer to an indirect array or indirect structure but you
cannot equivalence an indirect array or indirect structure to a standard pointer. A
pointer equivalenced to an indirect item is a read-only pointer—you can read the
address in the pointer, but you cannot store an address into the pointer.
When you declare indirect and extended pointers in equivalenced declarations:
•
The address type of a STRING standard pointer is BADDR. The address type of all
other standard pointers is WADDR.
•
The address type of extended pointers is always EXTADDR, regardless of the data
type of the objects to which the pointer will refer.
Figure 11-3 on page 11-13 shows two examples of the data types associated with
pointers. Figure 11-3 on page 11-13 shows the object data type and address type. Use
Table 11-4 on page 11-13 to determine valid equivalenced declarations.
Example 11-4. Read-Only Pointer
INT .a[0:3]; ! Indirect array
INT .b; ! Standard pointer
INT .c = a; ! OK: Equivalence a pointer to an indirect
! array (c is read-only)
INT .d[0:3] = b; ! ERROR: Cannot equivalence an indirect item
! to a pointer
@c := @c + 1; ! ERROR: Cannot modify a pointer that is
! equivalenced to an indirect item










