HP Pascal/iX Reference Manual (31502-90022)

10- 10
Parameter
f
A file variable that must be opened in the direct access state where
f
may not be omitted.
Description
The function maxpos(
f)
returns the integer index of the last component of
f
that the program could possibly access. An error occurs if
f
is not
opened as a direct access file. Note that the value returned is
implementation defined.
On implementations that allow direct access files to be extended, maxpos
returns the value of maxint or the maximum possible number.
Example
i:=maxpos(file_var) { File_var is the name of a file type variable }
open
Usage
open
(f)
open
(f, s)
open(f, s, t)
Parameters
f
A file variable that is not a textfile.
s
The name of a physical file that the system associates with
f
.
t
A string or PAC expression whose value is implementation dependent.
See the
HP Pascal/iX Programmer's Guide
or the
HP Pascal/HP-UX
Programmer's Guide,
depending on your implementation, for more
details.
Description
The procedure open(
f)
opens
f
in the direct state and places the current
position at the beginning of the file. The function eof returns false,
unless the file is empty. The buffer variable
f^
is undefined.
After a call to open,
f
is said to be a direct access file. Data may be
read or written using the procedures read, write, readdir, writedir, get
or put. The procedure seek and the functions lastpos and maxpos are also
legal. eof
(f)
becomes true when the current position is greater than the
highest-indexed component ever written to
f
.
Direct access files have a maximum number of components. The function
maxpos returns this number. The lastpos function returns the index of
the highest-written component of a direct access file.
A textfile cannot be opened for direct access since its format is
incompatible with direct access operations.
When the physical file specifier parameter is specified, the system
closes any physical file previously associated with
f
.
When
f
does not appear as a program parameter and
s
is not specified, the
system maintains any previous association of a physical file with
f
. If
there is no such association, it opens a temporary, nameless file. This
file cannot be saved. It becomes inaccessible after the process
terminates or the physical-to-logical file association changes. For more
information, see the
HP Pascal/iX Programmer's Guide
or the
HP
Pascal/HP-UX Programmer's Guide
, depending on your implementation.
Example
open(file_var)
open(file_var,phys_file_string)
open(file_var,phys_file_string,opt_str)
open(file_var,'TESTFILE')
Illustration
Suppose examp_file is a file of
integer
with three components. To