HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)
G- 7
20 CALL Test2 ! Call is made to Test1
30 _Test2 ! Implicit local declaration Call is made to Test1
In the following example, the explicit local declaration takes precedence
over the explicit global declaration.
10 GLOBAL ANYPARM EXTERNAL Test2 ALIAS "Test3" ! Explicit global declaration
20 ANYPARM EXTERNAL Test2 ALIAS "Test1" ! Explicit local declaration
30 CALL Test2 ! Call is made to Test1
In the following example, the implicit local declaration takes precedence
over the explicit global declaration in the main subunit. However, in
the Suba subunit, the explicit global declaration is used to determine
which external to call.
10 GLOBAL ANYPARM EXTERNAL Test2 ALIAS "Test1" ! Explicit global declaration
30 _Test2 ! Implicit local declaration Call is made to Test2
40 CALL Suba
50 END
60 SUB Suba
70 CALL Test2 ! Call is made to Test1 as specified in GLOBAL declaration
80 SUBEND
An explicit local external declaration also takes precedence over
implicit local ANYPARM declarations. In the following example, a call is
made to the Pascal external, Test4, using the ANYPARM underscore. Avoid
calls to non-ANYPARM externals using the ANYPARM underscore.
10 EXTERNAL PASCAL Test4 ! Explicit local external Pascal declaration
20 _Test4 ! Call is made to the external Pascal procedure Test4
Writing ANYPARM External Procedures
Writing an ANYPARM external procedure requires a thorough understanding
of the method that HP Business BASIC/XL uses to implement ANYPARM calls.
This section is divided into two subsections. The first subsection
describes the requirements for formal parameters to be included in the
procedure header and the actual parameter table passed to the ANYPARM
external procedure. The second subsection describes the internal data
structures that HP Business BASIC/XL uses to store the values of
variables in memory.
Requirements for the External Procedure
The external procedure must have two formal parameters. The first is a
value parameter to which is passed the number of parameters in the call's
actual parameter list. The second is a value parameter to which is
passed the address of the actual parameter table. In the MPE XL
operating system environment, the first parameter type must be a 4 byte
integer, and the second parameter type must be a 4 byte pointer.
The first formal parameter (the number of actual parameters) must be
checked prior to using the address of the formal parameter table. If the
number of actual parameters is zero, the address is set the value of
Pascal's NIL pointer constant. On the MPE XL based HP 3000, this value
is the four byte integer, 0.
The Actual Parameter Table
HP Business BASIC/XL prepares for the call to the external by building
the actual parameter table. First, it must be determined whether the
actual parameter is an HP Business BASIC/XL variable, an expression, or a
literal. Expressions are evaluated and the result is assigned to a
temporary variable. Literals are assigned to temporary variables of the
appropriate type. If the value is a temporary variable, the address of
the temporary variable is entered into the actual parameter table.
Otherwise, the actual parameter is an HP Business BASIC/XL variable, the
address of which is entered into the actual parameter table. The second
entry to the actual parameter table is the type of value present. The
third entry is the dimensionality of the value at the specified address.
If the value is a scalar, then the dimensionality is zero. Otherwise,
the dimensionality is the number of dimensions of the HP Business