SEEK statement
- Last Updated: January 18, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Positions the file pointer to a user-defined offset in a text file. This statement does not require you to close and reopen the file.
Syntax
|
- INPUT
- If you specify INPUT, the SEEK statement positions the file pointer in the unnamed input stream.
- OUTPUT
- If you specify OUTPUT, the SEEK statement positions the file pointer in the unnamed output stream.
- STREAM stream
- If you specify STREAM stream, the SEEK statement positions the file pointer in the named input or output stream. If you do not name a stream, the AVM uses the unnamed stream.
- STREAM-HANDLE handle
- If you specify the handle to a stream, the SEEK statement returns the current position of the file pointer in the stream. If handle it is not a valid handle to a stream, the AVM generates a run-time error.
- TO expression
- An expression whose value is INT64 that indicates the byte location to position the file pointer. If expression equals 0, the file pointer is positioned to the first byte in the file. If you want to position the pointer to the last byte in the file, but you do not know the offset, use END.
- END
- Positions the pointer to the last byte in the file.
Example
Since text file formats differ on each machine, the SEEK function does not necessarily return a number that is meaningful to anyone, but it is meaningful to the SEEK statement. With the exception of SEEK to 0 or SEEK TO END, any address used in the SEEK statement is only guaranteed to behave consistently if the address was previously derived from the SEEK function. Therefore, an expression such as SEEK TO SEEK (INPUT) -n might work differently on different operating systems. Record delimiters must be new-lines on UNIX, and carriage-return/linefeed pairs on all others.
r-seek.p
|
Notes
- The SEEK statement does not work with named streams identified in the INPUT-THROUGH, OUTPUT-THROUGH, or INPUT-OUTPUT-THROUGH statements.
- An expression such as SEEK TO SEEK (INPUT) -n might work differently on different operating systems.
- For more information on streams, see the topics on alternate I/O sources in OpenEdge Programming Interfaces.
See also
DEFINE STREAM statement, INPUT FROM statement, OUTPUT TO statement, SEEK function, Stream object handle