Parameter | Description |
---|---|
sName | The fully qualified name of the file to write |
eInEncoding | The file's character encoding format which may be OEM (CP_OEMCP), ANSI (CP_ACP), UTF-8 (CP_UTF8) or UTF-16 (-1) |
VDat | Variant string data to be written |
Procedure WriteFileFromVariantStr String sName Integer eInEncoding Variant VDat
Call: | Send WriteFileFromVariantStr sName eInEncoding VDat |
WriteFileFromVariantStr creates and writes a sequential file based on the contents of a Variant string. The passed encoding format (OEM, ANSI, UTF-8 or UTF-16) determines the encoding format for the file. The data will be converted from the Variant's string Unicode to the specified format.
If the format is OEM or ANSI, it is possible that Unicode data will not fit the code page and that the encoding will be "lossy". Using a Variant string means you do not need to worry about disposing of the data. Refer to cCharTranslate for a complete description of using Variant strings for this purpose.
// write an OEM document from a variant string Move (sAppSrc +"\OEM Document.txt") to sName Send WriteFileFromVariantStr of oFileHelper sName CP_OEMCP v1 // write an ANSI document from a variant string Move (sAppSrc +"\ANSI Document.txt") to sName Send WriteFileFromVariantStr of oFileHelper sName CP_ACP v1 // write a UTF-8 document from a variant string Move (sAppSrc +"\UTF8 Document.txt") to sName Send WriteFileFromVariantStr of oFileHelper sName CP_UTF8 v1 // write an UTF-16 document from a variant string (would be unusual to have a UTF-16 file) Move (sAppSrc +"\UTF16 Document.txt") to sName Send WriteFileFromVariantStr of oFileHelper sName -1 v1
Use ReadFileToVariantStr to read a file in a specified format encoding format into a Variant string.