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

9- 21
PRINT(chr,10,0);
len := ASCII(sint,-10,cint);
len := ASCII(sint2,-10,cint2);
PRINT(cint,-2,0);
PRINT(cint2,-2,0);
pas(chr,sint,sint2,sum);
PRINT(chr,10,0);
len := ASCII(sum,-10,csum);
PRINT(csum,-2,0);
END.
Pascal procedure:
$HP3000_16$
$SUBPROGRAM$
PROGRAM example;
TYPE
arr = PACKED ARRAY [1..20] OF char;
small_int = -32768..32767;
PROCEDURE pas(VAR carr : arr;
sint : small_int;
sint2 : small_int;
VAR sum : small_int);
BEGIN
carr := 'Sum of two numbers: ';
sum := sint1 + sint2;
END;
BEGIN
END.
How To Do Pascal I/O with a Non-Pascal Outer Block
Normally, the outer block of a Pascal program allocates space for the
default text files stdin, stdout, and stderr. The outer block allocates
space even if these files are referenced through Pascal modules (see
Appendix A and Appendix B ). The outer block also opens these
standard files.
In addition, the outer block performs initialization for trap handling
for TRY_RECOVER and for the standard Pascal module arg.
If the outer block is non-Pascal, the following routine can be used to
allocate space, open the default files, and initialize trap handling and
the module arg.
Example
To compile on MPE/iX, on the command line type:
pasxl initstuf,,$null;info="set 'hpux=false'"
To compile on HP-UX, on the command line type:
pc -c -Dhpux=true init_stuff.p
The file (initstuf on MPE/iX or init_stuff.p on HP-UX) is as follows:
{ how to have a non-pascal outer block and still do pascal i/o }
$if 'hpux'$
{ pascal doesn't buffer these files, uses hp-ux system calls }
{ also initialize the data for the module arg, and so that
the names on the command line are used for file opens. }
$endif$
$global; subprogram$ { allocates text files }