Chapter Contents

Previous

Next
FRLEN

FRLEN



Returns the size of the last record read, or, if the file is opened for output, returns the current record size

Category: External File


Syntax
Example
See Also

Syntax

length=FRLEN(file-id);

length
contains the length of the current record if the file is opened for output. Otherwise, it is the length of the last record read.

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


Example

Open the file identified by the fileref THEFILE. Determine the minimum and maximum lengths of records in the external file, and write the results to the LOG window.

   /* Assign the fileref THEFILE to the physical */
   /* filename stored in the variable FNAME      */
   /* and open it.                               */
rc=filename('thefile',fname);
fileid=fopen('thefile');
min=0;
max=0;
if (fread(fileid)=0) then do;
    min=frlen(fileid);
    max=min;
    do while(fread(fileid)=0);
       reclen=frlen(fileid);
       if (reclen>max) then max=reclen;
       if (reclen<min) then min=reclen;
    end;
    rc=fclose(fileid);
end;
put min= max=;

See Also

FCLOSE

FOPEN

FREAD


Chapter Contents

Previous

Next

Top of Page

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