Previous Page | Next Page

Functions and CALL Routines

FPOINT Function



Positions the read pointer on the next record to be read.
Category: External Files

Syntax
Arguments
Details
Examples
See Also

Syntax

FPOINT(file-id,note-id)


Arguments

file-id

is a numeric variable that specifies the identifier that was assigned when the file was opened, generally by the FOPEN function.

note-id

specifies the identifier that was assigned by the FNOTE function.


Details

FPOINT returns 0 if the operation was successful, or [ne]0 if it was not successful. FPOINT determines only the record to read next. It has no impact on which record is written next. When you open the file for update, FWRITE writes to the most recently read record.

Note:   You cannot write a new record in place of the current record if the new record has a length that is greater than the current record.  [cautionend]


Examples

This example assigns the fileref MYFILE to an external file and attempts to open the file. If the file is opened successfully, it reads the records and uses NOTE3 to store the position of the third record read. Later, it points back to NOTE3 to update the file, and closes the file afterward:

%let filrf=myfile;
%let rc=%sysfunc(filename(filrf,
   physical-filename));
%let fid=%sysfunc(fopen(&filrf,u));
%if &fid > 0 %then
   %do;
         /* Read first record. */
      %let rc=%sysfunc(fread(&fid));
         /* Read second record. */
      %let rc=%sysfunc(fread(&fid));
         /* Read third record. */
      %let rc=%sysfunc(fread(&fid));
         /* Note position of third record. */
      %let note3=%sysfunc(fnote(&fid));
         /* Read fourth record. */
      %let rc=%sysfunc(fread(&fid));
         /* Read fifth record. */
      %let rc=%sysfunc(fread(&fid));
         /* Point to third record. */
      %let rc=%sysfunc(fpoint(&fid,&note3));
         /* Read third record. */
      %let rc=%sysfunc(fread(&fid));
         /* Copy new text to FDB. */
      %let rc=%sysfunc(fput(&fid,New text));
         /* Update third record  */
         /* with data in FDB. */
      %let rc=%sysfunc(fwrite(&fid));
         /* Close file. */
      %let rc=%sysfunc(fclose(&fid));
   %end;
%let rc=%sysfunc(filename(filrf));


See Also

Functions:

DROPNOTE Function

FCLOSE Function

FILENAME Function

FNOTE Function

FOPEN Function

FPUT Function

FREAD Function

FREWIND Function

FWRITE Function

MOPEN Function

Previous Page | Next Page | Top of Page