STRTOFILE()

From Recital Documentation Wiki
Revision as of 16:34, 28 October 2009 by Helengeorge (Talk | contribs)

Jump to: navigation, search


Purpose

Function to write a text string out to a file


Syntax

STRTOFILE(<expC1>, <expC2> [, <expL> | <expN2>])


See Also

AT(), ATNEXT(), FCLOSE(), FCREATE(), FERROR(), FILETOSTR(), FOPEN(), FREADSTR(), FWRITE(), MEMOREAD(), MEMOWRITE(), STREXTRACT(), SUBSTR(), STUFF(), STR(), STRTRAN(), STRZERO(), TEXTEDIT(), TRIM()


Description

The STRTOFILE() function writes the specified string out to the specified file and returns the number of bytes written as a numeric.


Parameter Description
<expC1> String expression to be written to the file
<expC2> Name of the output file. This should include the path if not in the current directory. If it does not exist, it will be created.
<expL> If True (.T.), the string will be appended to the file's previous contents. If False (.F.), the string will overwrite the file's previous contents. The default is False.
<expN> Optional settings, see below.


The optional <expN> setting can be any of the following and used instead of <expL>:


Value Setting
0 The string will overwrite the file's previous contents.
1 The string will be appended to the file's previous contents.
2 The Unicode BOM "FF FE" will be written to the start of the file. The string will overwrite the file's previous contents.
4 The UTF-8 BOM "EF BB BF" will be written to the start of the file. The string will overwrite the file's previous contents.


Example

myString = "Hello World"
 
// Create file if it does not exist, overwrite if it does
nBytes = strtofile(mystring, "myfile.txt")
 
// Append to file's previous contents
nBytes = strtofile(mystring, "myfile.txt",.T.)
 
// Create file if it does not exist, overwrite if it does
nBytes = strtofile(mystring, "myfile.txt",0)
 
// Append to file's previous contents
nBytes = strtofile(mystring, "myfile.txt",1)
 
// Create file if it does not exist, overwrite if it does.  Include Unicode BOM
nBytes = strtofile(mystring, "myfile.txt",2)
 
// Create file if it does not exist, overwrite if it does.  Include UTF-8 BOM
nBytes = strtofile(mystring, "myfile.txt",4)


Products

Recital Database Server, Recital Mirage Server, Recital Terminal Developer