Click or drag to resize

MemoWrit Function (String, Byte)

X#
Write a string to a disk file.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax
 FUNCTION MemoWrit(
	cFileName AS STRING,
	cString AS BYTE[]
) AS LOGIC
Request Example View Source

Parameters

cFileName
Type: String
The name of the target disk file, including an optional drive, directory, and extension. SetDefault() and SetPath() settings are ignored; the Windows default is used unless you specify a drive and directory as part of the file name. No extension is assumed.
If cFileName does not exist, it is created.
If it exists, this function attempts to open the file in exclusive mode and, if successful, the file is overwritten without warning or error.
If access is denied because, for example, another process is using the file, MemoWrit() returns FALSE and NetErr() is set to TRUE.
cString
Type: Byte
The string to write to cFileName.

Return Value

Type: Logic
TRUE if the writing operation is successful; otherwise, FALSE.
Remarks
MemoWrit() is generally used with MemoRead() to load text files into memory, where they can be edited, displayed, and written back to disk. You can also use MemoWrit() as a quick way of exporting a memo field to a text file.
Tip Tip
Some characters, such as "ß," have different ANSI and OEM codes. When writing such characters from Windows to a file, you may need to issue the Ansi2Oem() function. Conversely, when reading the file back to Windows, you may need to issue an Oem2Ansi() function.
To circumvent such problems, MemoWrit() automatically does an ANSI to OEM conversion when SetAnsi() is FALSE.
Examples
This example uses MemoWrit() to save the contents of a field to a text file:
X#
1USE Sales
2IF MemoWrit("votmp.txt", Sales->Notes)
3    ? "Saved"
4ELSE
5    ? "Error while writing cliptmp.txt"
6    BREAK
7ENDIF
See Also