An Overview of ANYPARM [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation
HP Business BASIC/XL Reference Manual
An Overview of ANYPARM
HP Business BASIC/XL's ANYPARM external call feature is designed to allow
external calls with any number of actual parameters to a procedure in an
Executable Library or in an object file that is linked into a compiled
program file. Multiple calls to the same external procedure within an HP
Business BASIC/XL program need not have the same number of actual
parameters if the external is designed to process those parameters.
Scalar and array variables of any HP Business BASIC/XL data type can be
passed as actual parameters. String and numeric literals are legal as
actual parameters. Also, both string and numeric functions that are
evaluated prior to the external call are legal actual parameters.
Two methods are provided for calling ANYPARM external procedures. The
first method utilizes an explicit ANYPARM EXTERNAL declaration and the
CALL statement. The second method implements calls to the external by
prefixing the name of the external to be called with an underscore. In
the second method, a local implicit external declaration is made by HP
Business BASIC/XL at the beginning of the execution of the subunit in
which the call is made.
External procedures in the executable library that are to be called using
the ANYPARM feature are written so that there are two formal parameters.
The first is the number of actual parameters passed from HP Business
BASIC/XL. The second formal parameter of the external procedure is a
pointer to a formatted table of actual parameter information. The table
contains the following information:
* 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.
MPE/iX 5.0 Documentation