Click or drag to resize

FWriteLine Function

Write a string, a carriage-return character, and a linefeed character to an open file.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION FWriteLine(
	 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 <nBytes> is not specified, the value of SLen(<cBuffer>) is used.

Return Value

Type: UInt32
The number of bytes written.  If the value returned is equal to <nBytes> + 2, the operation was successful.  If the return value is less than <nBytes> + 2 or 0, this means that the length of  <cBuffer> was less than <nBytes>, or the disk is full, or another error has occurred.
Remarks
FWriteLine() is a low-level file function that writes data to an open file from a string buffer.  You can either write all or a portion of the buffer contents.  Writing begins at the current file position, and the function returns the actual number of bytes written. This function is assumed to handle raw binary data and is not dependent upon the status of SetAnsi().  FWriteText() and FWrite4(), on the other hand, are dependent upon SetAnsi().
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 uses FWriteLine() to write lines starting at the beginning of a file.  The carriage-return/linefeed pair increase the return value by 2:
X#
hF := FOpen2("c:\data\sales", FO_READWRITE)
IF hF != F_ERROR
        ? FWriteLine(hF, "Line1")                // 7
        ? FWriteLine(hF, "Line1", 2)        // 4
ENDIF
See Also