Calling SPL from HP Pascal [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation
HP Pascal/iX Programmer's Guide
Calling SPL from HP Pascal
SPL is a Compatibility Mode language only. The SPL routine that your HP
Pascal program calls must reside in a Compatibility Mode SL, and you must
write a switch stub to access it from your HP Pascal program. The switch
stub cannot be written in SPL. (See "Switch Stubs" .)
The directive EXTERNAL SPL passes parameters the same way in HP Pascal as
it does in Pascal/V.
Table 9-4 matches corresponding HP Pascal and SPL types. (It
contains only the types that are acceptable for formal intrinsic
parameters.) The variable n is an integer.
Table 9-4. Corresponding HP Pascal and SPL Types
---------------------------------------------------------------------------------------------
| | |
| HP Pascal Type | Corresponding SPL Type |
| | |
---------------------------------------------------------------------------------------------
| | |
| Array: Not PACKED | Array of corresponding type. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Array: PACKED | Array of corresponding type. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Bit16 | Logical. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Bit32 | Array of logical |
| | |
---------------------------------------------------------------------------------------------
| | |
| Bit52 | Array of logical |
| | |
---------------------------------------------------------------------------------------------
| | |
| Boolean (false = 0, true = 1) | Byte (odd is false, even is true). |
| | |
---------------------------------------------------------------------------------------------
| | |
| Char | Byte. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Enumeration 256 or fewer elements | Byte. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Enumeration 257 or more elements | Logical. |
| | |
---------------------------------------------------------------------------------------------
| | |
| File | Not available. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Function | Typed procedure. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Function parameter or variable | Not available. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Integer | Double. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Longint | Array of logical |
| | |
---------------------------------------------------------------------------------------------
| | |
| Longreal (HP3000_16) | Longreal. |
| | |
---------------------------------------------------------------------------------------------
| | |
| PAC of n characters | Byte array. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Pointer Not EXTNADDR | Not available. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Pointer EXTNADDR | Not available. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Procedure | Procedure. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Procedure parameter or variable | Not available. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Real (HP3000_16) | Real. |
| | |
---------------------------------------------------------------------------------------------
Table 9-4. Corresponding HP Pascal and SPL Types (cont.)
---------------------------------------------------------------------------------------------
| | |
| HP Pascal Type | Corresponding SPL Type |
| | |
---------------------------------------------------------------------------------------------
| | |
| Record | Not available, but you can lay out the |
| | equivalent. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Set | Not available. |
| | |
---------------------------------------------------------------------------------------------
| | |
| Shortint | Integer. |
| | |
---------------------------------------------------------------------------------------------
| | |
| String | Not available, but you can lay out the |
| | equivalent. |
| | |
---------------------------------------------------------------------------------------------
| | |
| String[n] (by value only) | Not available, but you can lay out the |
| | equivalent. |
| | |
---------------------------------------------------------------------------------------------
| | |
| VAR parameter Not EXTNADDR | Address of parameter. |
| | |
---------------------------------------------------------------------------------------------
| | |
| VAR parameter EXTNADDR | Not available. |
| | |
---------------------------------------------------------------------------------------------
| | |
| -32768..32767 | Integer. |
| | |
---------------------------------------------------------------------------------------------
| | |
| 0..65535 | Logical. |
| | |
---------------------------------------------------------------------------------------------
Example 1
The Pascal program Pascal_SPL calls the external SPL routine splprc.
Pascal program:
$HP3000_16$
PROGRAM Pascal_SPL (input,output);
TYPE
char_str = PACKED ARRAY [1..20] OF char;
small_int = -32768..32767;
VAR
a_str : char_str;
int1,
int2,
sum : small_int;
PROCEDURE splprc (VAR cstr : char_str;
inta : small_int;
intb : small_int;
VAR total : small_int); EXTERNAL SPL;
BEGIN
a_str := 'Add these 2 numbers:';
int1 := 25;
int2 := 15;
writeln(a_str,int1,int2);
splprc(a_str,int1,int2,sum);
writeln(a_str,sum);
END.
SPL routine:
$CONTROL SUBPROGRAM
BEGIN
PROCEDURE splprc(cstr,int1,int2,sum);
VALUE int1,int2;
INTEGER int1,int2,sum;
BYTE ARRAY cstr;
BEGIN
sum := int1 + int2;
MOVE cstr := "Sum of two numbers: ";
END;
END.
Example 2
The Pascal program Pascal_SPL_V calls splprv, an external SPL routine
with variable parameters.
Pascal program:
$HP3000_16$
PROGRAM Pascal_SPL_V (input,output);
TYPE
char_str = PACKED ARRAY [1..20] OF char;
small_int = -32768..32767;
VAR
a_str : char_str;
int1,
int2,
sum : small_int;
PROCEDURE splprv (VAR cstr : char_str;
inta : small_int;
intb : small_int;
VAR total : small_int);
EXTERNAL SPL VARIABLE;
BEGIN
a_str := 'Add these 2 numbers:';
int1 := 25;
int2 := 15;
writeln(a_str,int1,int2);
splprv(a_str,int1,int2,sum);
writeln(a_str,sum);
END.
SPL routine with variable parameters:
$CONTROL SUBPROGRAM
BEGIN
PROCEDURE splprv(cstr,int1,int2,sum); OPTION VARIABLE;
VALUE int1,int2;
INTEGER int1,int2,sum;
BYTE ARRAY cstr;
BEGIN
sum := int1 + int2;
MOVE cstr := "Sum of two numbers: ";
END;
END.
MPE/iX 5.0 Documentation