Chapter Contents

Previous

Next
FREAD

FREAD



Reads a record from an external file into the File Data Buffer (FDB)

Category: External File


Syntax
Details
Example
See Also

Syntax

sysrc=FREAD(file-id);

sysrc
contains the return code for the operation:
0 successful
[ne]0 not successful

Type: Numeric

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

Type: Numeric


Details

The position of the file pointer is automatically updated after the read operation so that successive FREAD functions read successive file records.

Use FNOTE, FPOINT, and FREWIND to position the file pointer explicitly.


Example

Assign the fileref MYFILE to an external file and attempt to open the file. Read each record from the file and list it in the LOG window.

   /* Assign the fileref MYFILE to the physical */
   /* filename stored in the variable FNAME     */
   /* and open it.                              */
rc=filename('myfile',fname);
fileid=fopen('myfile');
if (fileid>0) then
   do while(fread(fileid)=0);
      rc=fget(fileid,c,200);
      put c;
   end;
rc=fclose(fileid);
rc=filename('myfile','');

See Also

FGET

FNOTE

FPOINT

FREWIND


Chapter Contents

Previous

Next

Top of Page

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