Chapter Contents

Previous

Next
FPOS

FPOS



Sets the position of the column pointer in the File Data Buffer

Category: External File


Syntax
Details
Example
See Also

Syntax

sysrc=FPOS(file-id,nval);

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

nval
is the number of the column at which to set the pointer.

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

FCOL

FPUT


Chapter Contents

Previous

Next

Top of Page

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