HP Pascal/iX Programmer's Guide (31502-90023)
3-: 11
(VAR fpathname : pac100;
foption : integer;
mode : integer) : integer; EXTERNAL;
BEGIN
tmpnam(name); {get unique name for temporary file}
mode := octal('666'); {read-write access for file}
option := octal('402'); {specify read-write access}
fnum := file_open(name,option,mode); {open the 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 text file 'UDC'}
writeln('This is a test'); {write to file}
close(e,'SAVE'); {close text file 'UDC'}
name := 'UDC'#0; {open the same file through HP-UX}
mode := octal('666');
fnum := file_open(name,0,mode);
associate(g,fnum,'READ'); {associate with 'UDC' for seq. read access}
read(g,buffer);
tmpnam(name); {open text file through HP-UX}
mode := octal('666');
option := octal('401'); {specify write access}
fnum := file_open(name,option,mode);
associate(h,fnum,'WRITE'); {associate for sequential write access}
writeln(h,'This is a test');
END.
Disassociate Procedure
The predefined procedure
disassociate
removes the logical-physical file
association that was previously created with the standard procedure
associate. As a result, you can no longer use the file f with Pascal
input and output routines.
Syntax
disassociate (
f
)
Parameters
f
A variable of type file.
Normally, a file is closed on exit from the block in which it is
declared. A disassociated file, however, remains open until it is closed
with a direct call to an operating system routine.
Disassociate is useful on a file that is opened by a non-Pascal routine
that is passed to a Pascal routine and must remain open on exit from the
Pascal routine.
Sequential Input/Output
Sequential input/output
is input/output that is performed with sequential
files; that is, files whose current position indexes advance one
component at a time. Sequential input comes from read-only files that
the procedure
reset
opened. Sequential output goes to write-only files
that the procedure rewrite or append opened.
Table 3-4 summarizes the characteristics of the predefined sequential
input/output procedures.