FWrite Function | |
Write a string to an open file.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION FWrite(
ptrHandle,
cBuffer,
nBytes
) AS DWORD CLIPPER
[ClipperCallingConventionAttribute(new string[] { ... })]
public static uint FWrite(
Usual ptrHandle = default,
Usual cBuffer = default,
Usual nBytes = default
)
Request Example
View SourceParameters
- ptrHandle (Optional)
- Type: Usual
The handle of the file to write to. - cBuffer (Optional)
- Type: Usual
The string to write. - nBytes (Optional)
- 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:
DWord
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. When a disk full error occurs, FError() is set to 256.
FWrite() and FWrite3 are assumed to handle raw binary data and are not dependent upon the status of SetAnsi(). FWriteText() and FWrite4(), on the other hand, are dependent upon SetAnsi().
Remarks Remarks 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:
1DEFINE F_BLOCK := 512
2...
3cBuffer := Space(F_BLOCK)
4nInfile := FOpen2("temp.txt", FO_READ)
5nOutfile := FCreate("newfile.txt", FC_NORMAL)
6lDone := FALSE
7DO WHILE !lDone
8 nBytesRead := FRead(nInfile, @cBuffer,;
9 F_BLOCK)
10 IF FWrite(nOutfile, cBuffer) < SLen(cBuffer)
11 ? DOSErrString(FError())
12 lDone := TRUE
13 ELSE
14 lDone := (nBytesRead = 0)
15 ENDIF
16ENDDO
17FClose(nInfile)
18FClose(nOutfile)
See Also