Chapter Contents |
Previous |
Next |
FGET |
Category: | External File |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
sysrc=FGET(file-id,cval<,length>); |
0 | successful |
-1 | the end of the FDB was reached, or no more tokens were available. |
Type: Numeric
Type: Numeric
Note: This parameter is an update parameter. See
Input, Output, and Update Parameters for more information.
Type: Character
Type: Numeric
Details |
FGET copies data from the FDB into a character variable. If length is specified, then only the specified number of characters is retrieved (or the number of characters remaining in the buffer, if that number is less). If length is omitted, then all characters in the FDB from the current column position to the next delimiter are returned. The default delimiter is a blank. The delimiter is not retrieved. (See FSEP for more information about delimiters.)
After FGET is executed, the column pointer is automatically moved to the next "read" position in the FDB.
Example |
Read the first record in the file specified by the user and copy the first token into the variable THESTRING.
/* Assign the fileref THEFILE to the physical */ /* filename that is stored in the */ /* variable FNAME and open it in append mode. */ rc=filename( 'thefile',fname); fileid=fopen('thefile'); if (fileid>0) then do; /* Read the first record, retrieve the */ /* first token of the record and store */ /* it in the variable THESTRING. */ rc=fread(fileid); rc=fget(fileid,thestring); put thestring; rc=fclose(fileid); end; rc=filename('thefile','');
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.