Click or drag to resize

FWriteText Function

Write a string to an open file, with SetAnsi() dependency.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION FWriteText(
	 ptrHandle AS USUAL,
	 cBuffer AS USUAL,
	 nBytes AS USUAL
) AS DWORD
View Source

Parameters

ptrHandle
Type: Usual
The handle of the file to write to.
cBuffer
Type: Usual
The string to write.
nBytes
Type: Usual
The number of bytes in <cBuffer> to write, beginning at the current file pointer position.  If omitted, the entire contents of <cBuffer> is written.

Return Value

Type: UInt32
The number of bytes written.  If the value returned is equal to <nBytes>, the operation was successful.  If the return value is less than <nBytes> or 0, this means that the length of <cBuffer> is less than <nBytes>, or the disk is full, or another error has occurred.  FError() can be used to determine the specific error.
Remarks
FWriteText() is the same as FWrite() except that an ANSI to OEM conversion is made if SetAnsi() is FALSE.
Remarks
Tip Tip
This function is included for compatibility. We do not recomment using static memory for file i/o operations. We recommend that you use the function overload that takes a byte array parameter in stead.
Examples
This example copies the contents of one file to another.
X#
DEFINE F_BLOCK := 512
...
cBuffer := Space(F_BLOCK)
// turn on OEM <=> ANSI conversions
SetAnsi(FALSE)
nInfile := FOpen2("temp.txt", FO_READ)
nOutfile := FCreate("newfile.txt", FC_NORMAL)
lDone := FALSE
DO WHILE !lDone
        nBytesRead := FReadText(nInfile, @cBuffer, F_BLOCK)
        IF FWriteText(nOutfile, cBuffer) <
                SLen(cBuffer)
                ? DOSErrString(FError())
                lDone := TRUE
        ELSE
                lDone := (nBytesRead = 0)
        ENDIF
ENDDO
FClose(nInfile)
FClose(nOutfile)
See Also