Progress
Language Reference
SEEK Function
Returns the offset of the file pointer in a text file. You define a procedure variable to hold the offset value and later position the file to that offset.
SYNTAX
INPUT
If you specify INPUT, the SEEK function returns the current position of the file pointer in the unnamed input stream.
OUTPUT
If you specify OUTPUT, the SEEK function returns the current position of the file pointer in the unnamed output stream.
name
If you specify SEEK (name), the SEEK function returns the current position of the file pointer in the named input or output stream. The stream must be associated with an open file, or SEEK returns the unknown value (?).
EXAMPLEThis procedure shows how you can use the SEEK function to access data in an text file. Using SEEK this way allows you to index into a non-indexed file.
In the example, you are prompted to select an item number to position the output file. When a record is found with that item number, the SEEK function returns the offset into the variable m-pos. The value for m-pos is the current value of the file pointer. The SEEK statement uses the value in m-pos to position the file pointer in the unnamed input stream.
NOTES
- The first byte in a file is byte 0.
- You cannot use the SEEK function with the INPUT THROUGH statement, the INPUT-OUTPUT THROUGH statement, or the OUTPUT THROUGH statement. When used with one of these statements, the SEEK function returns the unknown value (?).
- After you assign the value of the SEEK function to a procedure variable, you can use that value to reposition the file in the event of an error.
- For more information on streams, see the chapter on alternate I/O sources in the Progress Programming Handbook .
SEE ALSO
DEFINE STREAM Statement, INPUT FROM Statement, OUTPUT TO Statement, SEEK Statement
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |