- Handling errors
- Operating mode in Windows Vista (and later)
- Carriage Return at the end of line
- Position in the file
fWrite (Function) In french: fEcrit Writes a block of bytes into an external file. Caution: The added elements are not inserted into the external file but they overwrite the existing elements.
New in version 28 Syntax
Writing a block of bytes into an external file Hide the details
<Result> = fWrite(<File used> , <Block to write> [, <Size to write>])
<Result>: Integer - Number of bytes written into the file.
- -1 if an error occurred. To get more details on the error, use ErrorInfo with the errMessage constant.
<File used>: Integer or DiskFile variable <Block to write>: Character string Block of bytes that must be written into the file (up to 2 GB).The format of the block of bytes is respected. No conversion is performed. <Size to write>: Optional integer Size of the string to write (in bytes). Remarks Handling errors fWrite throws an error in the following cases: - the file is not opened,
- the file is not accessible in write mode,
- the file is locked by another computer or by another application,
- no disk space is available.
Carriage Return at the end of line fWriteLine is used to automatically insert a carriage return (CR) at the end of the added line. To insert a Carriage Return (CR) with fWrite, simply use the CR constant. For example:
ResWrite = fWrite(FileID, "Report" + CR + "Sales - March 2021")
Position in the file When opening a file, the current position corresponds to: - the first file byte (by default),
- the last byte of the file is the file is opened in "addition" mode (foAdd constant).
This position can be modified by fSeek. fWrite writes the specified elements from the current position. Once fWrite has been executed, the current position is set to the last byte written. Remark: To always read the start, you must call fSeek and then fRead.
Related Examples:
|
Unit examples (WINDEV): Handling text files
[ + ] Handling "text" files with WINDEV: - Create a text file - Write into a text file - Read in a text file
|
|
Unit examples (WEBDEV): Handling text files
[ + ] This example explains how to handle "non HFSQL" files with WEBDEV and it allows you to: - Create a text file - Write into a text file - Read in a text file
|
|
Unit examples (WINDEV Mobile): Handling text files
[ + ] Handling external "text" files: - Create a text file - Write into a text file - Read in a text file
|
Business / UI classification: Business Logic
This page is also available for…
|
|
|
|