PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Method 1: Using the fReadLine function
  • Principle
  • Code samples
  • Method 2: Using the fLoadText function
  • Principle
  • Code sample
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
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 sample

// 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 required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment