Writes data to a file, starting at the position indicated by the file pointer.
Kernel.bdh
FWrite( in hFile : number, in sData : string, in nDataSize : number optional, in nWriteMode : number optional, out nWritten : number optional ): boolean;
true if successful
false otherwise
Parameter | Description |
---|---|
hFile | Valid handle to an open file. This handle must have been returned from a previous call to FOpen. |
sData | Buffer containing data to write |
nDataSize | Number of bytes to write (optional, default = STRING_COMPLETE). |
nWriteMode |
Specifies how the data is written to the file (optional). Possible values are:
|
nWritten | Variable receiving the number of bytes actually written (optional) |
dcltrans transaction TMain var hFile, nWritten : number; sOutput : string; begin // create a file in the temporary directory FOpen(hFile, "c:\\temp\\dummyfile.txt", OPT_FILE_ACCESS_READWRITE, OPT_FILE_CREATE); write("new file created"); writeln; // write string to open file sOutput := "Hello world!"; FWrite(hFile, sOutput, STRING_COMPLETE, OPT_FILE_APPEND, nWritten); write (nWritten); write(" bytes written to file"); writeln; // close file FClose(hFile); write("file closed"); writeln; end TMain;
new file created 12 bytes written to file file closed