HP Pascal/iX Programmer's Guide (31502-90023)
7- 13
IF j IN [-10..-1] THEN procvar2 := addr(gamma)
ELSE IF j IN [0..10] THEN procvar2 := addr(delta);
{Call procvar1 and procvar2, unless they are nil}
IF procvar1 = nil THEN writeln('i is out of range')
ELSE call(procvar1,i,j);
IF procvar2 = nil THEN writeln('j is out of range')
ELSE call(procvar2,i,j);
END.
Call Procedure
The predefined procedure
call
executes a call to the procedure specified
by a procedure variable. Its parameters are a procedure variable and the
actual parameters with which the procedure is to be called. Just as a
pointer is dereferenced with ^, a procedure variable is dereferenced with
call
.
Example
$STANDARD_LEVEL 'EXT_MODCAL'$
PROGRAM prog;
TYPE
proctype = PROCEDURE (x,y : integer);
VAR
procvar : proctype;
PROCEDURE p (a,b : integer);
BEGIN
.
.
.
END;
BEGIN
procvar := addr(p);
call(procvar,1000,3500);
p(1000,3500);
END.
The calls to the procedures
call
and
p
are semantically equivalent.
The first parameter to
call
(procedure variable) cannot have the value
nil
or be undefined.
Fcall Function
The predefined function
fcall
executes a call to the function specified
by a function variable. Its parameters are a function variable (which
specifies the function to be called) and the actual parameters with which
the function is to be called. Just as a pointer is dereferenced with ^,
a function variable is dereferenced with
fcall
.
Example
$STANDARD_LEVEL 'EXT_MODCAL'$
PROGRAM prog;
TYPE
functype = FUNCTION (x,y : integer) : integer;
VAR
funcvar : functype;