ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / How to proceed? / Managing the database
  • Overview
  • Method 1: Browse functions
  • Example
  • Method 2: FOR EACH statement
  • 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
Overview
Two methods can be used to perform the full browse of a data file:
Method 1: Browse functions
This method uses the WLanguage functions to loop through the data files:
In this method:
  • HReadFirst is used to access the first record according to the search key.
  • HReadNext is used to access the next record (in the order of search key).
  • HOut is used to find out whether the end of file was reached.
Remark: You have the ability to use HReadLast and HReadPrevious to perform a browse in reverse order.

Example

// Browse all records of Customer file
// sorted by customer name.
 
HReadFirst(CUSTOMER, CustomerName)
WHILE NOT HOut(CUSTOMER)
// Process the CUSTOMER record
HReadNext(CUSTOMER, CustomerName)
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.
The FOR EACH statement expects the following parameters:
  • the name of the file to browse
  • the name of the index (or key) to sort the records
The first record and the next record are read by the FOR EACH statement. There is no need to use the HReadXXX functions.
Remark: The DESC word allows you to perform a browse in reverse order.

Code example

// Browse all records of Customer file.
// Browse sorted by ascending name
 
FOR EACH CUSTOMER ON CustomerName
// Process the CUSTOMER record
 
 
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