Functions.MemoWrit Method (String, String)
Write a string to a disk file.
XSharp.Core (in XSharp.Core.dll) Version: 2.16
Syntax Request Example
cFileName AS STRING,
cString AS STRING
) AS LOGIC
public static bool MemoWrit(
- 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.
- Type: String
The string to write to cFileName.
TRUE if the writing operation is successful; otherwise, FALSE.
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.
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.
This example uses MemoWrit() to save the contents of a field to a text file:
2IF MemoWrit("votmp.txt", Sales->Notes)
3 ? "Saved"
5 ? "Error while writing cliptmp.txt"