ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / How to proceed? / Programming
  • Method 1: Using the fReadLine function
  • Principle
  • Code samples
  • Method 2: Using the fLoadText function
  • Principle
  • Code example
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Method 1: Using the fReadLine function

Principle

To read a line in a text or CSV file:
  1. Open the file with fOpen.
  2. Read the line with fReadLine.
  3. Close the file with fClose.

Code samples

  • Reading a line:
    // Read a simple string
    nFileNum is int
    sLineRead is string
     
    nFileNum = fOpen ("MyFile.txt", foRead)
    IF nFileNum <> -1 THEN
    // Read the line
    sLineRead = fReadLine(nFileNum)
    fClose(nFileNum)
    END
  • Reading a data file in TXT format (import)
    nFileNum is int
    sLineRead is string
     
    nFileNum = fOpen ("ImportProducts.txt", foRead)
    IF nFileNum <> -1 THEN
    sLineRead = fReadLine(nFileNum) // Read the 1st line
    WHILE sLineRead <> EOT // Check the end of file
    // Process the line
    ...
    // Read the next line
    sLineRead = fReadLine(nFileNum)
    END
    fClose(nFileNum)
    END
Method 2: Using the fLoadText function

Principle

To read a text or CSV file in a single operation:
  1. Declare a string variable.
  2. Load the entire file content in memory in this variable with fLoadText.
  3. Process the string in memory to analyze its content.

Code example

// Read a data file in TXT (import)
 
sFileContent is string
sLine is string
 
// Load the file content in memory
sFileContent = fLoadText("ImportProducts.txt")
 
FOR EACH STRING sLine OF sFileContent SEPARATED BY CR
// Process the line
...
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 10/27/2022

Send a report | Local help