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

3- 10
Example 1
This example applies to HP Pascal on the MPE/iX operating system only.
For a description of the MPE/iX intrinsic FOPEN, refer to the
MPE/iX
Intrinsics Reference Manual
.
PROGRAM test;
TYPE
pac100 = PACKED ARRAY [1..100] OF char;
VAR
f : FILE OF integer; {f is not a textfile}
buffer : pac100;
name : pac100;
fnum : integer;
j : integer;
e,g,h : text;
FUNCTION FOPEN : shortint; INTRINSIC; {MPE/&XL; file-opening intrinsic}
BEGIN
fnum := FOPEN(,0,octal('44'),-4); {open direct access read-write temp. file}
associate(f,fnum,'READ,WRITE,DIRECT'); {associate with file for
read-write direct access}
writedir(f,3,5);
readdir(f,3,j);
rewrite(e,'UDC'); {create file 'UDC'}
writeln('This is a test');
close(e,'SAVE'); {close file 'UDC'}
name := 'UDC';
fnum := FOPEN(name,octal('40')); {open 'UDC' for sequential read access}
associate(g,fnum,'READ'); {associate with 'UDC' for seq. read access}
read(g,buffer);
fnum := FOPEN(,4,octal('101')); {open write access sequential temp. file}
associate(h,fnum,'WRITE'); {associate for sequential write access}
writeln(h,'This is a test');
END.
Example 2
This example applies to HP Pascal on the HP-UX operating system only.
For descriptions of the HP-UX routines tmpnam and open, refer to the
HP-UX Reference
manual.
PROGRAM test;
TYPE
pac100 = PACKED ARRAY [1..100] OF char;
VAR
f : FILE OF integer; {f is not a textfile}
buffer : pac100;
name : pac100;
mode : integer;
fnum : integer;
j : integer;
e,g,h : text;
option : integer;
{External HP-UX routine that returns a unique file name}
PROCEDURE tmpnam (VAR fpathname : pac100); EXTERNAL;
{External HP-UX routine that opens a file}
FUNCTION file_open $ALIAS 'open'$ {use alias to avoid conflict w/Pascal open}