- Looper control based on a data file automatically initialized
- Looper control based on a data file initialized programmatically
Looper control linked to a data file
A Looper control can be used to display the content of a data file or the content of a query.
When a Looper control is linked to a data file or to a query, the looper can be initialized with the content of the data file or with the content of the query:
- automatically: No specific code is required to initialize the Looper control. The characteristics of the iteration performed in the data file bound to the control are defined in the "Content" tab of the control description.
- through programming: The code used to loop through the data file linked to the Looper control must be entered in the different processes of the control. This method is not recommended.
Remark: When creating a Looper control, the wizard asks for the information required to create a Looper control linked to a data file or to a query.
Looper control based on a data file automatically initialized
A Looper control based on a data file displays data from a specific data source (data file, query, etc.).
The content of the control is defined during its creation and it can be modified in its description window ("Content" tab).
This tab allows you to define whether the Looper control is based on a data file or variable, or if it is populated programmatically. For a Looper control based on a data file, this tab is used to define the characteristics of the iteration performed in the data source:
|Data file or query containing the data to display.|
|Item whose value is returned to the program when a row element is selected.|
|If this option is checked, WINDEV, WINDEV Mobile or WEBDEV manage how the data file is looped through and how the data is displayed in the Looper control. No WLanguage code is required.|
|Item used to loop through the data source. The information displayed in the Looper control will be sorted according to this item.|
|The iteration direction depends on the browse item. The iteration direction is defined in the data model editor, in the characteristics of the item. |
If this option is checked, the iteration direction used will be the opposite of the one defined in the data model editor.
- Display the records whose search key starts with:
|Condition used to filter the displayed records. This is a "Start with" filter and is applied to the browse item. To implement more complex filters, use HFilter.|
Looper control based on a data file initialized programmatically
If you are using a Looper control based on a data file with programmed initialization, the code for looping through the data file must be written in the different processes associated with the control. This method is not recommended and it is kept for backward compatibility.
For example: Initializing a Looper control with the products found in the Product data file.
// The LOOP_LOOPER1 Looper control contains 5 captions and an image
// 6 attributes are used to modify the value of captions and the image displayed
// Initialize the looper from the content of an HFSQL data file
WHILE NOT HOut()
LooperAdd(LOOP_LOOPER1, Product.ProductName + TAB + Product.Duration + ...
TAB + Product.Director + TAB + Product.Actor + ...
TAB + Product.Photo + TAB + Product.Designation)
This page is also available for…