STRTOFILE()

Top  Previous  Next

Writes a string into a file.

Syntax

STRTOFILE( cData, cFilename, lAppend )

Parameters

cData

String that is written to the file. Depending on the string and current Unicode support, the string might be converted. See the Remarks section for details.

 

cFilename

A file name into which the string is written. The file name must specified according to the rules of the operating system. You can specify a fully qualified name or a relative name. Relative file names are resolved relative to the current directory.

 

lAppend

Specifies what happens when the file exists.

 

Value

Description

.F.

(default).

 

When SET SAFETY is OFF, the existing content is replaced with cData and the file resized accordingly.

 

When SET SAFETY is ON, the user is asked whether the existing file should be replaced. If not, the content does not change and cData is not written. If yes, the existing contents gets replaced with cData.

.T.

If the file exists, cData is appended to the end of the file. Otherwise the file is created anew.

Return value

Returns the number of bytes that have been written. With Unicode support enabled the number bytes does not match the number of characters in the string.

Remarks

STRTOFILE() creates a Unicode file with UTF8 encoding when Unicode support is enabled. This occurs independently on whether the string in cData is a Unicode or ANSI string. Despite writing in UTF-8 format no corresponding preamble is written to file.

 

Unicode strings are converted to ANSI string when Unicode mode is disabled. Any character that has not representation in the ANSI character set of the current code page is replaced with a question mark. To create binary files you must disable Unicode support and write an ANSI string into the file.

 

STRTOFILE() prompts the user to overwrite the file, if the file exists and SET SAFETY is ON.

Compatibility

Visual WebGUI: Even with SET SAFETY ON Guineu never prompts the user for confirmation and implicitly assumes that the user wants to overwrite the file.

See also

SET SAFETY

SYS(8000) - Unicode support