HP 3000 Manuals

Calling COBOL II from HP Pascal [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation


HP Pascal/iX Programmer's Guide

Calling COBOL II from HP Pascal 

The table and example in this section assume that the HP Pascal program
and the COBOL II routine that it calls are both compiled in Native Mode.
If the COBOL II routine is in a Compatibility Mode SL instead, you must
write a switch stub to access it from your HP Pascal program (see "Switch
Stubs" ).

Table 9-2  matches corresponding HP Pascal and COBOL II types.  (It
contains only the types that are acceptable for formal intrinsic
parameters.)  The variable n is an integer.

          Table 9-2.  Corresponding HP Pascal and Cobol II Types 

---------------------------------------------------------------------------
-           HP Pascal Type           -    Corresponding Cobol II Types    -
---------------------------------------------------------------------------
| Array:   Not PACKED                | Array of corresponding type.       |
|                                    | Specify SYNC.                      |
---------------------------------------------------------------------------
| Array:       PACKED                | Array of corresponding type.       |
|                                    | Do not specify SYNC.               |
---------------------------------------------------------------------------
- Boolean (false = 0, true = 1)      - Not available.                     -
---------------------------------------------------------------------------
- Char                               - PIC X (8 bits).                    -
---------------------------------------------------------------------------
- Enumeration                        - Not available.                     -
---------------------------------------------------------------------------
- File                               - Not available.                     -
---------------------------------------------------------------------------
- Function                           - Not available.                     -
---------------------------------------------------------------------------
- Function parameter or variable     - Not available.                     -
---------------------------------------------------------------------------
| Integer                            | (1) PIC S9(5) to S9(9)             |
|                                    | (2) Level 01, 77, or SYNC without  |
|                                    | $CONTROL SYNC 16                   |
|                                    | (3) COMP or BINARY                 |
---------------------------------------------------------------------------
- Longreal                           - Not available.                     -
---------------------------------------------------------------------------
- PAC of n characters                - PIC X(n) (8 bits).                 -
---------------------------------------------------------------------------
- Pointer                            - Not available.                     -
---------------------------------------------------------------------------
- Procedure                          - Not available.                     -
---------------------------------------------------------------------------
- Procedure parameter or variable    - Not available.                     -
---------------------------------------------------------------------------
- Real                               - Not available.                     -
---------------------------------------------------------------------------
- Record                             - Build equivalent record.           -
---------------------------------------------------------------------------
- Set                                - Not available.                     -
---------------------------------------------------------------------------
| Shortint                           | Any one of the following:          |
|                                    | (1) PIC S9 to S9(4)                |
|                                    | (2) LEVEL 01, 77, or SYNC          |
|                                    | without $CONTROL SYNC 16           |
|                                    | (3) COMP or BINARY                 |
---------------------------------------------------------------------------
- String                             - Not available.                     -
---------------------------------------------------------------------------
- String[n]                          - Build equivalent record.           -
---------------------------------------------------------------------------
- VAR parameter                      - Default.                           -
---------------------------------------------------------------------------

Example 

The Pascal program Pascal_COBOL calls the external COBOL II routine
subprog1.

Pascal program:

     PROGRAM Pascal_COBOL (input,output);

     VAR
        int1,
        int2,
        int3 : integer;

     PROCEDURE subprog1 (VAR parm1 : integer;
                         VAR parm2 : integer;
                         VAR parm3 : integer); EXTERNAL COBOL;

     BEGIN
        int1 := 25000;
        int2 := 30000;
        subprog1(int1,int2,int3);
        writeln(int3);
     END.

COBOL routine:

     $CONTROL SUBPROGRAM
      IDENTIFICATION DIVISION.
      PROGRAM-ID. SUBPROG1.
      AUTHOR. BP.
      DATA DIVISION.
      LINKAGE SECTION.
      77 IN1      PIC S9(07) COMP.
      77 IN2      PIC S9(07) COMP.
      77 OUT      PIC S9(07) COMP.
      PROCEDURE DIVISION USING IN1, IN2, OUT.
      PARA-1.
        ADD IN1, IN2, GIVING OUT.
        EXIT PROGRAM.



MPE/iX 5.0 Documentation