HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)

G- 3
* The address of the value of each actual parameter stored in the
format specified by that parameter's HP Business BASIC/XL data type.
* The type of the parameter at that address.
* A value indicating whether the parameter is a scalar or, if it is an
array, the number of dimensions.
Data Structures in HP Business BASIC/XL
In order to correctly manipulate the actual parameters, it is important
to have a thorough understanding of the data structures that HP Business
BASIC/XL uses.
The method used to pass the actual parameters from the HP Business
BASIC/XL program to the external procedure precludes the type checking of
actual parameters. Therefore, HP Business BASIC/XL has no method of
determining the number or the type of the parameters expected to be
present in the table of actual parameters located at the address
specified by the second formal parameter of the external procedure.
Since only the addresses of the actual parameters are passed in the
table, all HP Business BASIC/XL variables that are actual parameters are
passed by reference. If a numeric or string constant or expression is an
actual parameter, a temporary variable is created to store the value and
the address of the temporary variable is passed.
On the return from the external procedure, HP Business BASIC/XL has no
method for determining whether its internal data structures or data areas
have been destructively altered. The programmer writing the external
procedure needs to thoroughly understand the ramifications of the
external procedure's interactions with all areas of memory. Direct heap
management, which includes heap allocation in one external call and
deallocation in a subsequent call, interferes with HP Business BASIC/XL's
internal heap management and should be avoided.
Error Handling and Program Development
Error handling within the external procedure is the responsibility of the
external procedure. HP Business BASIC/XL uses the XARITRAP intrinsic to
replace MPE XL's arithmetic trap handler. HP Business BASIC/XL uses
XLIBTRAP to enable an HP Business BASIC/XL library trap procedure. Use
of either the XARITRAP or XLIBTRAP intrinsics will interfere with HP
Business BASIC/XL's trap handling mechanism and should be avoided.
Programming errors encountered during development of the external
procedure can be difficult to debug. Knowledge of the machine
instruction set and the system debug facility prove to be invaluable
tools in facilitating rapid program development. Relevant information is
contained in the
Precision Architecture and Instruction Manual
, and the
MPE XL Debug Reference Manual
.
ANYPARM Calls From HP Business BASIC/XL
There are two methods of calling external procedures written to be called
by the ANYPARM method. The first utilizes HP Business BASIC/XL's
EXTERNAL and CALL statements. The second implements the underscore (_)
to call the external. In both calling methods, the programmer has the
responsibility for ensuring that the external being called is compatible
with the formal parameter interface used by HP Business BASIC/XL's
ANYPARM calling feature.
The external procedure can be included in any executable library. The
order for resolving external procedure references for HP Business
BASIC/XL programs executing in the interpreter is the same as that
specified in the LIB = or XL = parameter when the interpreter is invoked.
If the program is a compiled program, then the search order is the same
as when the compiled program is starts executing.
Using ANYPARM EXTERNAL and CALL
The ANYPARM EXTERNAL statement is used to explicitly declare procedures
that are to be called using the ANYPARM call feature. The CALL statement