PreviousNextIndex

SEEK function

Returns the offset of the file pointer in a text file as an INT64 value. You define a procedure variable to hold the offset value and later position the file to that offset.

Syntax

SEEK ( { INPUT | OUTPUT | name | STREAM-HANDLE handle } ) 

INPUT
OUTPUT
name
STREAM-HANDLE handle
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 NO-UNDO LIKE Item.ItemNum. 
DEFINE VARIABLE itdesc NO-UNDO LIKE Item.ItemName. 
DEFINE VARIABLE m-pos  AS INT64 NO-UNDO. 
SET itemno LABEL 
  "Select a record number to position the output file" WITH SIDE-LABELS. 
OUTPUT TO test.fil. 
FIND Item NO-LOCK WHERE Item.ItemNum = itemno. 
IF Item.ItemNum = itemno THEN 
  m-pos = SEEK(OUTPUT). 
EXPORT Item.ItemNum Item.ItemName. 
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, Stream object handle


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex