HP Pascal/iX Programmer's Guide (31502-90023)

9- 8
Pascal program:
PROGRAM Pascal_C2 (output);
VAR
str : string[40];
FUNCTION c_read (VAR s : string) : Boolean; EXTERNAL C;
BEGIN
setstrlen(str,0);
IF c_read(str) THEN
writeln('str = ', str)
ELSE
writeln('couldn''t read str');
END.
C routine:
#include <stdio.h>
int c_read(s) /* no Boolean type in C */
char *s;
{
return (fgets(stdin,s) >= 0);
}
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. -
---------------------------------------------------------------------------