Chapter Contents

Previous

Next
FWRITE

FWRITE



Writes a record to an external file

Category: External File


Syntax
Details
Example
See Also

Syntax

sysrc=FWRITE(file-id<,cc>);

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

cc
specifies a carriage-control character:
'0' skips one blank line before a new line.
'-' skips two blank lines before a new line.
'1' starts the line on a new page.
'+' overstrikes the line on a previous line.
'P' interprets the line as a terminal prompt.
'=' interprets the line as carriage-control information.

Any other character (including a blank) starts the record on a new line.

If cc is not provided, FWRITE writes to the current line.

Type: Character


Details

FWRITE moves text from the File Data Buffer (FDB) to the external file. In order to use the carriage-control characters, you must open the file with a RECORD format of P (PRINT format) with FOPEN.


Example

Write the numbers 1 to 50 to an external file, skipping two blank lines. Then call FSLIST to display the newly created file.

   /* Assign the fileref THEFILE to the external */
   /* filename stored in the variable FNAME.     */
rc=filename('thefile',fname);
fileid=fopen('thefile','o',0,'P');
do i=1 to 50;
   rc=fput(fileid,put(i,2.));

 if (fwrite(fileid,'-') ne 0) then do;
    _msg_=sysmsg();
    put msg;
    return;
  end;
end;

rc=fclose(fileid);
call fslist('thefile','cc');

See Also

FAPPEND

FGET

FPUT


Chapter Contents

Previous

Next

Top of Page

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