PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Managing errors
  • Position in the file
  • Managing the ANSI/UNICODE format
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Writes a line into an external file. The characters required to go to the next line are automatically inserted at the end of the added line.
Versions 15 and later
Android This function is now available for the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 16 and later
Universal Windows 10 App This function is now available for the Windows Phone applications.
New in version 16
Universal Windows 10 App This function is now available for the Windows Phone applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Windows Mobile
// Open an external file
FileID = fOpen("\MyDirectories\File.txt", foReadWrite)
IF FileID <> -1 THEN
// Write a line into this file
ResWrite = fWriteLine(FileID, "Status report of meeting")
IF ResWrite = False THEN
...
END
END
Syntax

Writing a line into an external file Hide the details

<Result> = fWriteLine(<File identifier> , <Line to write>)
<Result>: Boolean
  • True if the write operation was performed into the specified file,
  • False if an error occurred. To find out the error details, use ErrorInfo associated with the errMessage constant.
<File identifier>: Integer
Identifier of the file to use, defined by fOpen or fCreate.
<Line to write>: Character string (with quotes)
Line that must be written into the file (up to 2GB).
AndroidAndroid Widget Windows Mobile

Writing a fixed-length line into an external file (speeds up the write operation) Hide the details

<Result> = fWriteLine(<File identifier> , <Address of line to write> , <Size to write>)
<Result>: Boolean
  • True if the write operation was performed into the specified file,
  • False if an error occurred. To find out the error details, use ErrorInfo associated with the errMessage constant.
<File identifier>: Integer
Identifier of the file to use, defined by fOpen or fCreate.
<Address of line to write>: Address
Address of the line that must be written into the file.
<Size to write>: Integer
Size in bytes (characters) of the line that must be written (up to 2GB).
This parameter must be less than or equal to the real size of the wine written into the external file. For example, if the size of the line to write is equal to 100 bytes, <Size to write> must be less than or equal to 100 bytes.
If this parameter is less than the real size of the written line, only the specified number of bytes will be written into the text file. The line will be truncated.
Windows Mobile Reminder: In UNICODE, each character occupies two memory bytes.
Remarks

Managing errors

fWriteLine generates 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.
Caution: fWriteLine can only be used on text files. This function does not support the binary 0 (the write operation is stopped).

Position in the file

When opening a file, the current position corresponds to:
  • the first byte of the file (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.
fWriteLine writes the specified elements from the current position. Once fWriteLine has been run, the current position corresponds to the last byte written.

Managing the ANSI/UNICODE format

fWriteLine is used to write:
  • a Unicode string into a Unicode file.
  • an Ansi string into an Ansi file.
The file was created or opened by fCreate/fOpen while specifying the file type.
Remarks:
  • The size to write into Unicode file a must be multiplied by two compared to an ANSI file.
  • If a character string in ANSI format is written into a UNICODE file (and conversely), the conversion will be implicitly performed.
    Format of the string passed in parameter
    External file
    in ANSI format
    (fOpen or fCreate associated with the foAnsi constant)
    External file
    in UNICODE format
    (fOpen or fCreate associated with the foUnicode constant)
    fWriteLineANSINo conversion is required before the write operationAutomatic conversion of the string before the write operation
    UNICODEAutomatic conversion of the string before the write operationNo conversion is required before the write operation
In the WINDEV and WEBDEV projects, in version 16 and in version 17 ("Use the ANSI strings at run time" option in the description of the project configuration), the opening mode used by default is foAnsi (1st column).
In the WINDEV and WEBDEV projects, in version 17 and in Unicode mode ("Use the UNICODE strings at run time" option in the description of the project configuration), the opening mode used by default is foUnicode (second column).
In the WINDEV Mobile projects, regardless of the version and mode, the opening mode used by default is foUnicode (second column).
See Managing the UNICODE for more details
Related Examples:
Handling text files 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
Handling text files 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
Handling text files 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
The TableTo functions Unit examples (WINDEV): The TableTo functions
[ + ] Exporting table data with the WLanguage functions.
The following topics are presented in this example:
1/ interfacing with Word and Excel
2/ sending data to the clipboard
3/ generating a text file
This example explains how to export the content of a table to a Word document, an Excel workbook, the clipboard or a text file via the following WLanguage functions: TableToWord, TableToExcel, ToClipboard, TableToText.
Component : wd240std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment