Progress
Language Reference


SEEK Function

Interfaces
OS
SpeedScript
All
All
Yes

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

SEEK ( { INPUT | OUTPUT | name } ) 

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 (?).

EXAMPLE

This 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.

r-seek1.p
DEFINE VARIABLE itemno LIKE item.item-num.
DEFINE VARIABLE itdesc LIKE item-name.
DEFINE VARIABLE m-pos AS INT.

SET itemno LABEL
  "Select a record number to position the output file" WITH SIDE-LABELS.
OUTPUT TO test.fil.
FIND item WHERE itemno = item-num.

IF item-num = itemno
THEN m-pos = SEEK(OUTPUT).

EXPORT item-num item-name.
OUTPUT CLOSE.

INPUT FROM test.fil.
SEEK INPUT TO m-pos.
SET itemno itdesc WITH FRAME d2.
INPUT CLOSE. 

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

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