Chapter Contents

Previous

Next
FNOTE

FNOTE



Identifies the last record that was read

Category: External File


Syntax
Details
Example
See Also

Syntax

note-id=FNOTE(file-id);

note-id
contains the identifier assigned to the last record that was read. The note-id value is used by the FPOINT function to reposition the file pointer on a particular record. SCL programs should not modify the value of the note-id variable.

Type: Numeric

file-id
is the identifier that was assigned when the file was opened. If file-id is invalid, the program halts.

Type: Numeric


Details

You can use FNOTE like a bookmark, marking the position in the file so that your application can later use FPOINT to return to that position.

FNOTE is limited to noting 1,000 records. When that limit is reached, the program halts. To free the memory that is associated with each note identifier, use DROPNOTE.


Example

Assign the fileref THEFILE to an external file. Then attempt to open the file. If the file is successfully opened, indicated by a positive value in the variable FID, then read the records, use the variable NOTE3 to save the position of the third record that is read, and then later use FPOINT to point to NOTE3 to update the file. After the record is updated, close the file.

   /* Assign the fileref THEFILE to the        */
   /* filename stored in the variable FNAME    */
   /* and open it in UPDATE mode.              */
rc=filename('thefile',fname);
fileid=fopen('thefile','u');
if (fileid>0) then do;
      /* Read the first record. */
   rc=fread(fileid);
      /* Read the second record. */
   rc=fread(fileid);
      /* Read the third record. */
   rc=fread(fileid);
      /* Note the position of third record. */
   note3=fnote(fileid);
      /* Read the fourth record. */
   rc=fread(fileid);
      /* Read the fifth record. */
   rc=fread(fileid);
      /* Point to the third record. */
   rc=fpoint(fileid,note3);
      /* Read the third record. */
   rc=fread(fileid);
      /* Copy the new text to the FDB. */
   rc=fput(fileid,'New text');
      /* Update the third record with data in the FDB. */
   rc=fwrite(fileid);
      /* Close the file. */
   rc=fclose(fileid);
end;
   /* Deassign the fileref.  */
rc=filename('thefile','');

See Also

DROPNOTE

FPOINT

FREAD

FREWIND


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.