PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Managing errors
  • Position in the file
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
Reads a block of bytes in an external file.
AndroidAndroid Widget JavaPHP In this version, you can only read a character string from an external file in ANSI format.
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.
WINDEVWEBDEV - Server codeReports and QueriesJavaPHPAjaxUser code (UMC)
// Open an external file
FileID = fOpen("C:\MyDirectories\File.txt", foReadWrite)
IF FileID <> -1 THEN
// Read operation in this file
ResRead = fRead(FileID, 200)
...
END
Windows Mobile
// Open an external file
FileID = fOpen("\MyDirectories\File.txt", foReadWrite)
IF FileID <> -1 THEN
// Read operation in this file
ResRead = fRead(FileID, 200)
...
END
Syntax

Reading a block of bytes in an external file Hide the details

<Result> = fRead(<File Identifier> , <Number of Bytes to Read>)
<Result>: Character string
  • Block of bytes that was read.
  • Empty string ("") 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.
PHP This parameter must be a variant.
<Number of Bytes to Read>: Integer
Number of bytes to read (up to 2 147 483 648 bytes).
If the data is a Unicode string, the number of bytes to read corresponds to:
  • in UTF16: the number of characters multiplied by 2.
  • in UTF32: the number of characters multiplied by 4.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadWindows MobileAjaxUser code (UMC)

Reading the content of an external file and assigning it to a memory zone (identified by its address) Hide the details

<Result> = fRead(<File Identifier> , <Number of Bytes to Read> , <Address>)
<Result>: Integer
  • Number of bytes read,
  • 0 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.
<Number of Bytes to Read>: Integer
Number of bytes to read (up to 2 147 483 648 bytes).
If the data is a Unicode string, the number of bytes to read corresponds to:
  • in UTF16: the number of characters multiplied by 2.
  • in UTF32: the number of characters multiplied by 4.
<Address>: Address
Address of affected memory section.
Remarks

Managing errors

fRead generates an error in the following cases:
  • the file is not opened,
  • the file is not accessible in read mode,
  • the file is locked by another computer or by another application,
  • therefore, the end of file is reached.

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.
fRead reads the specified elements from the current position. Once fRead has been run, the current position corresponds to the last byte read.
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
Components
WINDEVWEBDEV - Server codeReports and Queries wd230std.dll
Windows Mobile wp230std.dll
Java wd230java.jar
Linux wd230std.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment