System-Dependent Features [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation
HP Pascal/iX Programmer's Guide
System-Dependent Features
System dependent features are available to all HP Pascal programs
(regardless of the system on which the compiler is running), but the
system affects their definitions and behavior. System dependent HP
Pascal features fall into these categories:
* Compiler options.
* File names.
* Associating logical and physical files.
* Using file equations.
* Default file attributes.
* Standard modules.
* Miscellaneous.
Compiler Options
The following compiler options are available only to programs that are
compiled by the HP Pascal compiler running on the MPE/iX operating system
and contain the compiler option OS 'MPE/XL'.
FONT
HP3000_16
HP3000_32
The compiler option INCLUDE is available to programs compiled by the HP
Pascal compiler running on either the MPE/iX or HP-UX operating system,
but it works differently on the two systems.
Refer to the HP Pascal/iX Reference Manual for more information on the
compiler options FONT, HP3000_16, HP3000_32, and INCLUDE.
File Names
An MPE/iX file name has the syntax
filename [/lockword][.group[.account]][:nodename]
where each of filename, lockword, group, account and node is a string of
one to eight alphanumeric characters. The first character in the string
is a letter, and each of domain and organization is a string of one to 16
alphanumeric characters, the first of which is a letter. The entire file
name cannot have more than 86 characters. MPE/iX does not distinguish
between uppercase and lowercase letters.
Example
For more information on MPE/iX file names, refer to the MPE/iX Commands
Reference Manual.
Associating Logical and Physical Files
Your program does not affect its external environment unless its logical
files are associated with physical files at run-time. If they are, file
operations work concurrently on logical and physical files (see Chapter 3
).
In HP Pascal on the MPE/iX operating system, a logical file is associated
with a physical file under any one of the following conditions:
1. The name of the logical file is both a program parameter and the
first parameter of a predefined file-opening procedure. The
predefined file-opening procedure has no second parameter.
The operating system associates the logical file name with a
default physical file, whose name consists of the first eight
characters of the logical file name. This name must be an
acceptable MPE/iX file name (for example, it cannot contain an
underscore character (_)). If the default physical file does not
exist, HP Pascal creates a temporary physical file with that name.
Example
PROGRAM case_one (input,output,file1);
VAR
file1 : FILE OF integer;
BEGIN
reset(file1);
.
.
.
END.
The operating system associates the logical file file1 with the
physical file FILE1. If FILE1 does not exist, HP Pascal creates a
temporary file named FILE1.
The standard files input and output are exceptions to this scheme.
When they are program parameters, the operating system associates
them with the physical files $STDIN and $STDLIST, respectively.
If a logical file name is not a program parameter, but is the
first parameter of a file-opening procedure that has no second
parameter, the operating system associates the logical file with a
temporary, nameless physical file (assuming that the logical file
is not already associated with a physical file). You cannot save
the temporary file. When the program ends or the logical file is
associated with another physical file, the temporary file is
inaccessible.
2. The names of the logical and physical files are the first and
second parameters, respectively, of a predefined file-opening
procedure. It does not matter whether the logical file name is a
program parameter or not.
Example
PROGRAM case_two (input,output); {logical file name is not a
program parameter}
VAR
file1 : FILE OF integer;
BEGIN
rewrite(file1,'numfile');
.
.
.
END.
The operating system associates the logical file file1 with the
physical file numfile.
This association holds, even if the logical file name is a program
parameter.
Example
PROGRAM case_three (input,output,file1); {logical file name is a
program parameter}
VAR
file1 : FILE OF integer;
fname : PACKED ARRAY [1..8] OF char;
BEGIN
fname := 'numfile';
rewrite(file1,fname);
.
.
.
END.
The operating system still associates file1 with numfile, not
FILE1.
The second parameter of a file-opening procedure need not be a
string literal. It can also be a PAC variable or string
expression.
Using File Equations
The MPE/iX FILE command redirects the association of one physical file to
another physical file and specifies additional file attributes, which are
MPE/iX dependent.
Example
PROGRAM prog (outfile);
VAR
i : integer;
outfile : text;
BEGIN
rewrite(outfile);
FOR i := 1 TO 20000 DO
writeln(outfile,i);
END.
If PRG is the program file for prog and you execute the MPE/iX command
sequence
:FILE OUTFILE = FILE2
:RUN PRG
then output goes to FILE2 instead of OUTFILE.
If you execute the MPE/iX command sequence
FILE OUTFILE; DISC=21000; REC=-20,,F,ASCII
RUN PROG
then a nondefault attribute file is created.
Default File Attributes
When HP Pascal creates a file, the physical file attributes depend on the
file component type.
Table A-1 gives the default file attributes of files built by HP
Pascal programs. After the program has executed, the MPE/iX command
LISTF shows these values for the files that the program built (LISTF
attribute names are in parentheses).
Table A-1. Default File Attributes
-----------------------------------------------------------------------------------------------------
| | |
| How Program | Default File Attribute |
| Declares File | |
| | |
-----------------------------------------------------------------------------------------------------
| | | | | |
| | Record Size | File Type (TYP) | Current File Size | Maximum File Size |
| | (SIZE) | | (EOF) | (LIMIT) |
| | | | | |
-----------------------------------------------------------------------------------------------------
| | | | | |
| FILE OF type | Component size | Fixed length | Number of | 1023 |
| | | binary (FB) | components | |
| | | | written | |
| | | | | |
-----------------------------------------------------------------------------------------------------
| | | | | |
| Text | 256 bytes | Variable length | Number of lines | 1023 |
| | | ASCII with | written | |
| | | carriage control | | |
| | | (VAC) | | |
| | | | | |
-----------------------------------------------------------------------------------------------------
Standard Modules
Two standard modules are available on MPE/iX: stdinput and stdoutput.
If a module imports the stdinput module, it can use the predefined file
input in I/O statements such as read and readln.
If a module imports the stdoutput module, it can use the predefined file
output in I/O statements such as write and writeln.
Example
MODULE mymod;
IMPORT
stdinput, stdoutput;
EXPORT
FUNCTION myproc : integer;
IMPLEMENT
FUNCTION myproc : integer;
VAR
i : integer;
BEGIN
prompt('enter number:'); {need not specify output file}
readln(i); {need not specify input file}
myproc := i;
END;
END.
Additional Features
The HP Pascal features in the left-hand column depend on the MPE/iX
operating system in the ways explained in the right hand column.
Feature MPE/iX Dependency
Close options The optional third parameter of the
predefined procedure close can be SAVE,
LOCK, TEMP, NORMAL, CRUNCH, or PURGE, whose
meanings are:
SAVE LOCK The file is saved as a
permanent file after it is
closed.
TEMP NORMAL The file is saved as a
temporary file after it is
closed.
CRUNCH Space after end-of-file marker
is removed when the file is
closed.
PURGE The file is purged after it is
closed.
Halt MPE/iX calls the intrinsic QUIT with an
integer parameter.
Internal table size
The Job Control Word (JCW) PASXDATA is the
number of pages to allocate to each internal
table (there is one internal table for
identifiers and another for structured
constants). The default internal table size
is 100 pages. To set the internal table
size to n pages, use the command:
:SETJCW PASXDATA n
Write If the file being written is $STDLIST (the
default output file), the output is
unbuffered; therefore, a write to $STDLIST
has the same behavior as prompt.
Input The standard program parameter and textfile
input is $STDIN.
Maxpos The call maxpos(f) returns the position
number of the last component of the file f
that the program can access. It is an error
if the file f is not open for direct access.
Open options The third parameter of the predefined
file-opening procedures append, associate,
open, read, reset, rewrite, and write. They
and their meanings are:
Option Meaning
CCTL The file has carriage control.
(Ignored for associate.)
DIRECT The file is open for read and
write access (associate only).
NOCCTL The file does not have carriage
control. (Ignored for
associate.)
READ The file is open for read
access only (associate and open
only).
WRITE The file is open for write
access only (associate and open
only).
SHARED The file can be open to more
than one program at a time.
(Ignored for associate.)
EXCLUS The file cannot be open to more
than one program at a time.
(Ignored for associate.)
LOCK The file is locked. If the
file is already locked, the
program waits until it is
unlocked. (Ignored for
associate.)
At least one open option is required for
associate; for all other file-opening
procedures, open options are optional. You
can specify more than one open option
(separate them with commas).
If the physical file specified in the
associate procedure has one or more of the
characteristics specified by the open
options, then the logical file assumes the
same characteristics. If not, the associate
procedure does not associate the new
physical file with the logical file.
Output The standard program parameter and textfile
output is $STDLIST.
System intrinsic file SYSINTR.PUB.SYS
System default module PASLIB.PUB.SYS
library
Restrictions on Using Executable Libraries (XLs)
Global variables cannot be referenced across load modules. This applies
to globals declared through normal, global, external, and module
subprogram compilation units. In particular, you cannot use the standard
files input or output.
If a subprogram compilation unit is put in an XL, memory is overwritten.
You cannot put an external compilation unit in an XL. Using MODULE or
SUBPROGRAM with global compilation units will cause separate storage
locations to be allocated.
A non-local GOTO from an XL cannot branch to a label in the outer block.
MPE/iX 5.0 Documentation