Difference between revisions of "STRTOFILE()"

From Recital Documentation Wiki
Jump to: navigation, search
 
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
==Class==
 
String Data
 
 
 
 
==Purpose==
 
==Purpose==
 
Function to write a text string out to a file
 
Function to write a text string out to a file
Line 12: Line 8:
  
 
==See Also==
 
==See Also==
[[AT()]], [[ATNEXT()]], [[FCLOSE()]], [[FCREATE()]], [[FERROR()]], [[FILETOSTR()]], [[FOPEN()]], [[FREADSTR()]], [[FWRITE()]], [[MEMOREAD()]], [[MEMOWRITE()]], [[STREXTRACT()]], [[SUBSTR()]], [[STUFF()]], [[STR()]], [[STRTRAN()]], [[STRZERO()]], [[TEXTEDIT()]], [[TRIM()]]
+
[[AT()]], [[ATNEXT()]], [[FCLOSE()]], [[FCREATE()]], [[FERROR()]], [[FILETOSTR()]], [[FOPEN()]], [[FREADSTR()]], [[FWRITE()]], [[MEMOREAD()]], [[MEMOWRITE()]], [[SET STRESCAPE]], [[STREXTRACT()]], [[STUFF()]], [[STR()]], [[STRTRAN()]], [[STRZERO()]], [[SUBSTR()]], [[TEXTEDIT()]], [[TRIM()]]
  
  
Line 76: Line 72:
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital, Recital Server
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:String Data]]
 
[[Category:String Data]]
 
[[Category:String Data Functions]]
 
[[Category:String Data Functions]]

Latest revision as of 11:47, 21 July 2010

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(), SET STRESCAPE, STREXTRACT(), STUFF(), STR(), STRTRAN(), STRZERO(), SUBSTR(), 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, Recital Server