HP Pascal/iX Reference Manual (31502-90022)

11- 29
offset
A signed integer expression.
routine-name
The name of a procedure or function.
Description
The predefined function addr returns a pointer value that is the address
of the argument. The type of the pointer returned by addr is assignment
compatible with any pointer type.
Addr
returns a
short
or
long pointer
depending on the context in which it is called, the context being the
type of the target variable of an assignment, the type of a formal
parameter, or the target type of a type coercion.
If the type coercion target type is not a pointer type, addr returns a
globalanypointer.
If an integer argument is supplied, the pointer returned is offset by the
integer number of bytes from the original variable whose address was
taken.
It is illegal to take the address of a formal value or READONLY
parameter.
It is illegal to take the address of a component of a PACKED or CRUNCHED
structure, if the component does not begin on a byte-aligned boundary.
If addr is called with the name of a procedure or function, the value
returned is a reference to that procedure or function. The function
result type is assignment compatible with a PROCEDURE or FUNCTION type
whose parameter list is congruent with the parameter list of the routine
passed to addr.
If the name passed to addr cannot be resolved, the value NIL is returned.
Example
$STANDARD_LEVEL 'HP_MODCAL', TYPE_COERCION 'CONVERSION'$
TYPE
p_to_p_type = ^ p_to_p_type;
VAR
p_to_p : p_to_p_type;
BEGIN
p_to_p := addr( p_to_p );
p_to_p := p_to_p_type( addr( p_to_p^, sizeof( p_to_p^ ) ) )^;
END
The first assignment points the pointer p_to_p to itself. The second
assignment takes the address of the data referenced by p_to_p (which is
itself), offset by the size of the data that p_to_p points to, treats the
value at that location as a pointer, and assigns the value pointed to by
that pointer back to p_to_p.
Addtopointer.
The predefined function addtopointer allows the user to perform address
arithmetic with pointers.
Usage
addtopointer
(pointer, delta)
Parameters
pointer
A pointer expression.
delta
A signed integer expression whose range restriction