Predefined Modules [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation
HP Pascal/iX Programmer's Guide
Predefined Modules
On both the MPE/iX and HP-UX operating systems, HP Pascal has these
predefined modules:
* stdinput
* stdoutput
On the HP-UX operating system only, HP Pascal has these additional
predefined modules:
* stderr
* arg
* pas_hp1000
In its import declaration section, your program can import any or all of
the predefined modules supported by the operating system on which it
runs.
This section shows the actual declarations in the predefined modules for
your information only. Do not include these declarations in your
program. Instead, import the predefined modules as shown on the
following page.
stdinput
The stdinput module contains the declaration for the predefined global
variable (standard textfile) input. It allows an independent module
(which has no program header) to use input. Importing the stdinput
module into an independent module is the same as declaring input in the
program header of a program.
The content of the predefined module stdinput is:
VAR
input : text;
stdoutput
The stdoutput module contains the declaration for the predefined global
variable (standard textfile) output. It allows an independent module
(which has no program header) to use output. Importing the stdoutput
module into an independent module is the same as declaring output in the
program header of a program.
The content of the predefined module stdoutput is:
VAR
output : text;
stderr
The stdrrr module contains the declaration for the predefined global
variable (standard textfile) stderr. It allows an independent module
(which has no program header) to use stderr. Importing the stderr module
into an independent module is the same as declaring stderr in the program
header of a program.
The content of the predefined module stderr is:
VAR
stderr : text;
The predefined module stderr is only available on the HP-UX operating
system.
The main use of stdinput, stdoutput, and stderr is to allow a module to
perform a read or write operation to either standard input files,
standard output files, or, on HP-UX, standard error files. The module
must import the corresponding stdinput, stdoutput, or stderror modules,
and the program must have input, output, or stderr in the program header.
A main program does not need to import these standard modules, but the
corresponding program parameter must be present in the program header.
The following example shows a program importing a module that imports
stdinput, stdoutput, and, on HP-UX, stderr.
MODULE A;
EXPORT
Procedure getnum (var n:integer);
IMPLEMENT
IMPORT
stdinput, stdoutput, stderr;
Procedure getnum (var n: integer);
BEGIN
Writeln ('Enter a positive number') {Writes to output.}
Readln (n); {Reads from input.}
IF n < 0 THEN
Writeln (stderr, 'Incorrect input') {Writes to stderr.}
END;
END.
The program below shows how module A is imported. It is compiled into
file A.o. The program parameters input, output, and stderr must be
present since module A imports them. arg and pas_hp1000 do not need to
be present if they are imported.
Program Test (input, output, stderr);
$search 'A.o'$ { search A.o for module A }
IMPORT A:
VAR
m : integer;
BEGIN
getnum(m);
.
.
.
END.
arg
The arg module contains routines that access HP-UX command line
arguments. (It also contains the types that these routines use, but only
the routines are presented here.)
The routines in the predefined module arg are:
Routine Effect and Declaration
argc Returns the total number of arguments to the program (the
name of the program is considered to be the first
argument).
Declaration:
FUNCTION argc : integer;
argv Returns a pointer to an array of pointers to the actual
arguments.
Declaration:
FUNCTION argv : argarrayptr;
argn A specific argument, in the form of a Pascal string.
Declaration:
FUNCTION argn (argnum : integer) : String1024;
The predefined module arg is only available on the HP-UX operating
system.
pas_hp1000
The pas_hp1000 module contains routines that help you migrate Pascal/1000
programs to HP Pascal/HP-UX on the HP 9000 Series 700 or 800 machine.
They emulate user-callable routines in the Pascal/1000 run-time library.
The routines in the predefined module pas_hp1000 are:
Routine Effect and Declaration
pas_init_hp1000_args Only for programs running under the RTE shell on the
HP 9000 Series 700 or 800. Using command line
arguments, it sets up an HP-UX-like argument array
for use in argument-accessing routines.
Declaration:
PROCEDURE pas_init_hp1000_args;
pas_parameters Returns a specific argument to the program as a
Pascal PACKED ARRAY OF CHAR.
Declaration:
FUNCTION pas_parameters
( position : shortint;
ANYVAR Parameter : Pas_PAC80; {any PAC}
maxlen : shortint
) : shortint;
pas_sparameters Returns a specific argument to the program as a
Pascal string.
Declaration:
FUNCTION pas_sparameters
( position : shortint;
VAR Parameter : String; {Any string}
) : shortint;
pas_numericparms Interprets the arguments to the program as an array
of numeric strings and returns an array of numbers
corresponding to these strings.
Declaration:
PROCEDURE pas_numericparms
(ANYVAR ParmArray : Pas_ParmArray);
pas_getnewparms Only for programs running under the RTE shell on the
HP 9000 Series 700 or 800. Reinitializes the
argument data structures when the program has been
rescheduled after being suspended.
Declaration:
PROCEDURE pas_getnewparms;
pas_filenamr Returns the name of the physical file associated
with the specified logical file.
Declaration:
FUNCTION pas_filenamr
(ANYVAR f : text) : pas_nametype;
pas_timestring Returns the time of day as a 26-character PACKED
ARRAY OF CHAR.
Declaration:
PROCEDURE pas_timestring
(ANYVAR f : pas_timestringtype);
pas_traceback Produces a stack trace of the program and writes it
to stderr.
Declaration:
PROCEDURE pas_traceback
(dummy : shortint); {parameter is ignored}
pas_stringdata1 Return pointers to the data portion of a string.
pas_stringdata2 Functionally identical; provided as different entry
points for consistency with Pascal/1000 names.
Declarations:
FUNCTION pas_stringdata1
(VAR s : String) : localanyptr;
FUNCTION pas_stringdata2
(VAR s : String) : localanyptr;
The predefined module pas_hp1000 is only available on the HP-UX operating
system.
MPE/iX 5.0 Documentation