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

3-: 5
File Buffer Variables and Selectors
Every logical file has a
file buffer variable
, or
buffer
, which is a
variable of the same type as the file components. Some file operations
assign the value of the current component to the buffer; other operations
leave the buffer undefined.
When the buffer is defined, you can access its value with its
file buffer
selector
. The file buffer selector for the file f is f^ or f@.
Accessing an undefined buffer causes an error.
Opening Files
Except when using
input
and
output
files, your program must open files
before it can use them. A call to a predefined file-opening procedure
has the following syntax and parameters.
Syntax
{reset }
{rewrite} (
logical_file
[,
physical_file
[,
open_options
]])
{append }
{open }
Parameters
reset, rewrite, The names of the predefined file-opening procedures.
append, open See Table 3-2 for more information on them.
logical_file
The name of the logical file to be opened.
physical_file
A string or PAC expression whose value is the name of
the physical file to be opened. The syntax of the
file name is system-dependent (see Appendix A for
the MPE/iX operating system or Appendix B for the
HP-UX operating system).
open_options
A string or PAC expression whose value is a list of
file attributes. The syntax of the list is
system-dependent (see Appendix A for the MPE/iX
operating system or Appendix B for the HP-UX
operating system).
Example 1
reset(logfile);
rewrite(logfile2,physfile2);
append(lfile1,pfile1,'SHARED'); {HP-UX operating system ignores 'SHARED'}
open(lfile1);
If you specify
physical_file
, the system associates it with
logical_file
.
If
logical_file
was previously associated with another physical file, the
system closes the other physical file with its data intact and opens a
new physical file.
Example 2
PROGRAM prog;
VAR
datafile : FILE OF integer;
BEGIN
open (datafile, 'file1'); {Logical file datafile is associated with
physical file file1.}
open (datafile, 'file2'); {Physical file file1 is closed.
Logical file datafile is associated with