OPEN DATASET - position
Syntax
... AT POSITION pos ... .
Effect:
This addition sets the file pointer at the position specified in pos.
A numerical data object is expected for pos. As of release 6.10, digits with a value greater than the
value range of the data type i can also be entered.
The position is defined in bytes, and the start of the file is equal to position 0. If
pos contains the value -1, as of release 6.10 the file pointer is positioned at the end of the file. For all other negative values and prior to Release 6.10, the behavior is undefined.
Please note the following special cases:
-
If the file is opened for reading and the value of pos
is greater than the length of the file, the file pointer is positioned outside the file. If the position is not changed, no data can be read. In a non-
Unicode program, if a file is opened
for reading and is then written to, the file is filled with hexadecimal 0 from the end of the file to the specified position, and the new content is written after that.
-
If the file is opened for writing, the next time writing takes place, the file is filled with hexadecimal 0 from the start of the file to the specified position, and the new content is written after that.
-
If the file is opened for appending, the position specification is ignored and the file pointer remains positioned at the end of the file.
-
If the file is opened for changing, and the value of pos
is greater than the length of the file, the next time the file is written in, it is filled with hexadecimal 0 from the end of the file to the specified position, and the new content is written after that.
The addition POSITION cannot be specified if one of the
additions FILTER
or BYTE-ORDER MARK is specified at the same time.
Notes:
-
For file sizes larger than 2 GB, a position pos of the
data type i is not sufficient for positioning in the whole
file, and f or p must be used instead.
-
The positioning can be overwritten by the statement
SET DATASET . In particular, for positioning the file pointer at the end of the file,
SET DATASET should be used instead of entering the value -1 in pos.
-
Free position specifications are more suitable for binary files than for text files. In the case of text files, positions depend on the character representation,
end-of-line marking, and a possible byte order mark (BOM) in UTF-8 files. ________________________________________________________________________