How To Do Pascal I/O with a Non-Pascal Outer Block [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation
HP Pascal/iX Programmer's Guide
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 }
$literal_alias on$
program dick(input,output
$if 'hpux'$ ,stderr $endif$ );
$if 'hpux'$
type argtype = packed array[1..32000] of char;
argarray= array[0..32000] of ^argtype;
argarrayptr = ^argarray;
var argc $alias '__argc_value'$ : integer;
argv $alias '__argv_value'$ : argarrayptr;
env $alias '_environ'$ : argarrayptr;
procedure p_init_args $alias 'P_INIT_ARGS'$(c:integer;
v,e:argarrayptr); external;
$endif$
procedure u_init_traps $alias 'U_INIT_TRAPS'$; external;
(Example continued on next page.)
procedure initialize_pascal_standard_files;
begin
$if 'hpux'$
p_init_args(argc,argv,env); { initialize for module arg }
$endif$
u_init_traps; { initialize for trap handling }
{ now open standard files }
reset(input,'$stdin','shared');
rewrite(output,'$stdlist');
$if 'hpux'$
rewrite(stderr,'$stderr');
$endif$
end;
begin end.
MPE/iX 5.0 Documentation