PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Method 1: Browse functions
  • Code example
  • Method 2: FOR EACH statement
  • Code example
  • Method 3: HFilter function
  • Example
  • Method 4: Using an SQL query
  • Example
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
Overview
Several methods can be used to browse a data file according to a filter:
Method 1: Browse functions
This method is using the WLanguage functions to browse the data files:
HReadSeek is used to access the first record corresponding to the value of the minimum bound for the search key.
HReadNext is used to access the next record corresponding to the search.
HFound is used to find out whether there is a record corresponding to the search value.

Code example

// Browse the records of Customer file whose city is PARIS.

HReadSeek(CUSTOMER, City, "PARIS")
WHILE HFound(CUSTOMER)
// Process the CUSTOMER record

HReadNext(CUSTOMER, City)
END
Method 2: FOR EACH statement
The FOR EACH statement is used to browse the records found in a data file. In our case, this statement will be used to read the records found in a data file according to a filter.
The FOR EACH statement expects the following parameters:
  • the name of the data file to browse.
  • the name of the index (or key) used to sort the records.
  • the filtering value.
The first record and the next record are read by the FOR EACH statement. There is no need to use the HReadXXX functions.

Code example

// Browse the records of Customer file whose city is PARIS.
FOR EACH CUSTOMER WHERE CITY = "PARIS"
// Process the CUSTOMER record
END
Method 3: HFilter function
  1. Use HFilter to apply a filter of records to the data file.
  2. Browse the filtered data file with the stardard browse functions.
  3. At the end of browse, disable the filter with HDeactivateFilter.

Example

Finding orders whose date is included between 02/01/2017 and 02/28/2017.
// Apply the filter
HFilter(ORDER, ORDERDATE, "20170201", "20170228")

// Browse the file
FOR EACH ORDER
// Process the order read
END


// Disable the filter
HDeactivateFilter(ORDER)
Note: HFilter is easier to use than the previous methods. It can also be used to manage more filter capabilities. See the online help about HFilter for more details.
Method 4: Using an SQL query
To browse the data file with filter via a query:
  1. Create the query. The query is used to filter the requested records.
    Reminder: An SQL query can be performed:
    • in the query editor.
    • by programming.
    See Creating a query for more details.
  2. Run the query (fonction HExecuteQuery or HExecuteSQLQuery).
  3. Read the query result by browsing the data file.
  4. Free the query (HFreeQuery).

Example

HExecuteQuery(QRY_CustomerList)
FOR EACH QRY_CustomerList
// Process the customer read in the query
END
HFreeQuery(QRY_CustomerList)
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment