Difference between revisions of "FWRITE()"

From Recital Documentation Wiki
Jump to: navigation, search
(Products)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{YLM to do}}
 
doesn't send new lin
 
==Class==
 
ASCII File Access
 
 
 
 
==Purpose==
 
==Purpose==
 
Function to write a character expression to an ASCII file
 
Function to write a character expression to an ASCII file
Line 10: Line 4:
  
 
==Syntax==
 
==Syntax==
FWRITE(<expN1>, <expC> [,<expN2>])
+
FWRITE(<expN1>, <expC>[, <expN2>])
  
  
 
==See Also==
 
==See Also==
[[FCLOSE()]], [[FCREATE()]], [[FDATE()]], [[FERROR()]], [[FGETS()]], [[FOPEN()]], [[FREAD()]], [[FREADSTR()]], [[FTIME()]], [[MEMOREAD()]], [[MEMOWRITE()]], [[TEXTEDIT()]]
+
[[FCLOSE()]], [[FCREATE()]], [[FDATE()]], [[FERROR()]], [[FGETS()]], [[FOPEN()]], [[FPUTS()]], [[FREAD()]], [[FREADSTR()]], [[FTIME()]], [[MEMOREAD()]], [[MEMOWRITE()]], [[TEXTEDIT()]]
  
  
Line 20: Line 14:
 
The FWRITE() function writes the character expression <expC> to a specified text file.  The <expN1> is the file pointer returned by either the FOPEN() or FCREATE() functions.  The optional <expN2> specifies the maximum number of bytes to write from the buffer.
 
The FWRITE() function writes the character expression <expC> to a specified text file.  The <expN1> is the file pointer returned by either the FOPEN() or FCREATE() functions.  The optional <expN2> specifies the maximum number of bytes to write from the buffer.
  
The effect of FWRITE() is to write new lines sequentially to the opened text file each time it is used on the file.  If an error occurs during the operation -1 is assigned to the FERROR() function.  The file pointer must be assigned when the file is first opened using the FOPEN() or FCREATE() functions.
+
If an error occurs during the operation -1 is assigned to the FERROR() function.  The file pointer must be assigned when the file is first opened using the FOPEN() or FCREATE() functions.  FWRITE() does not include line terminators when writing to the file; this can be achieved using [[FPUTS()]].
  
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
use acc_log
+
fp=fcreate("time.txt")
scatter to flist
+
m_total=alen(flist)
+
fp=fcreate("new.txt")
+
 
if ferror()=-1
 
if ferror()=-1
 
     dialog box "The file could not be created."
 
     dialog box "The file could not be created."
 
else
 
else
     for n=1 to m_total
+
     fwrite(fp,timestamp())
        fwrite(fp,flist[n],80)
+
    next
+
 
endif
 
endif
 
fclose(fp)
 
fclose(fp)
Line 44: Line 33:
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital Server, Recital  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:ASCII File Access]]
 
[[Category:ASCII File Access]]
 
[[Category:ASCII File Access Functions]]
 
[[Category:ASCII File Access Functions]]

Latest revision as of 16:03, 2 December 2009

Purpose

Function to write a character expression to an ASCII file


Syntax

FWRITE(<expN1>, <expC>[, <expN2>])


See Also

FCLOSE(), FCREATE(), FDATE(), FERROR(), FGETS(), FOPEN(), FPUTS(), FREAD(), FREADSTR(), FTIME(), MEMOREAD(), MEMOWRITE(), TEXTEDIT()


Description

The FWRITE() function writes the character expression <expC> to a specified text file. The <expN1> is the file pointer returned by either the FOPEN() or FCREATE() functions. The optional <expN2> specifies the maximum number of bytes to write from the buffer.

If an error occurs during the operation -1 is assigned to the FERROR() function. The file pointer must be assigned when the file is first opened using the FOPEN() or FCREATE() functions. FWRITE() does not include line terminators when writing to the file; this can be achieved using FPUTS().


Example

fp=fcreate("time.txt")
if ferror()=-1
    dialog box "The file could not be created."
else
    fwrite(fp,timestamp())
endif
fclose(fp)
if ferror()=-1
    dialog box "The file could not be closed."
endif


Products

Recital Server, Recital