Chapter Contents

Previous

Next
FREWIND

FREWIND



Positions the file pointer at the beginning of the file

Category: External File


Syntax
Details
Example
See Also

Syntax

sysrc=FREWIND(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

FREWIND has no effect on a file that was opened with sequential access.


Example

Assign the fileref THEFILE to an external file. Then open the file and read the records until the end of the file is reached. The FREWIND function then repositions the pointer to the beginning of the file. The first record is read again and is stored in the File Data Buffer (FDB). The first token is retrieved and is stored in the variable VAL.

   /* Assign the fileref THEFILE to the physical */
   /* filename stored in the variable FNAME      */
   /* and open it.                               */
rc=filename('thefile',fname);
fileid=fopen('thefile');
do while (rc ne -1);
      /* Read a record. */
   rc=fread(fileid);
end;

   /* Reposition the pointer at the beginning of */
   /* the file.                                  */
if rc= -1  then rc=frewind(fileid);
   /* Read the first record. */
rc=fread(fileid);
   /* Read the first token into VAL. */
rc=fget(fileid,val);
put val= ;
rc=fclose(fileid);
rc=filename('thefile','');

See Also

FGET


Chapter Contents

Previous

Next

Top of Page

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