Chapter Contents |
Previous |
Next |
FPOS |
Category: | External File |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
sysrc=FPOS(file-id,nval); |
0 | successful |
0 | not successful |
Type: Numeric
Type: Numeric
Type: Numeric
Details |
If the specified position is past the end of the current record, then the size of the record is increased appropriately. However, in a fixed block file or a VBA file, if you specify a column position beyond the end of the record, the record size does not change, and the text string is not written to the file.
Example |
Assign the fileref THEFILE to an external file and then attempt to open the file. If the file is opened successfully, as indicated by a positive value in the variable FID, then place data into the file's buffer at column 12, write the record, and close the file.
/* Assign the fileref THEFILE to the physical */ /* filename stored in the variable FNAME */ /* and open it in append mode. */ rc=filename('thefile',fname); fileid=fopen('thefile','o'); if (fileid>0) then do; rc=fread(fileid); dataline='This is some data.'; /* Position at column 12 in the FDB. */ rc=fpos(fileid,12); /* Put the data in the FDB. */ rc=fput(fileid,dataline); /* Write the record. */ rc=fwrite(fileid); /* Close the file. */ rc=fclose(fileid); end; /* Clear the fileref. */ rc=filename('thefile','');
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.