2.4 · Record traversal & file tables

Level 2 · Intermediate: data, queries & reports

2.4Record traversal & file tables

Goal: Traverse data (POUR TOUT), fill Table controls and manage filtering/sorting according to volume.
Estimated time: 11 min · self-paced reading · If you only have 5 min: read “The essentials in 30s” + the diagram.

The essentials in 30 seconds

  • Traversal reviews the records of a file or a query; two approaches: the POUR TOUT loop (modern, recommended) and manual traversal (HLitPremier / HLitSuivant with an HEnDehors test).
  • The Table control displays several records; the file table is linked to a file or a query and fills automatically, loading only the displayed rows.
  • The memory table is filled by code (TableAjouteLigne): total freedom but loading to manage — reserve it for constructed data or controlled volumes.

Running mini-case — Yacine displays and traverses the product catalogue

Yacine, a WinDev developer at an SME trading electrical equipment in Oran, must display the product catalogue and identify those to restock. For the list shown on screen, he chooses a file table linked to a filtered query: it fills automatically and loads only the visible rows, even with thousands of references. To calculate stock alerts, he writes a traversal with the POUR TOUT Produit loop, concise and recommended, then adds the relevant lines to a second table. He takes care to also write the manual traversal (HLitPremier / HLitSuivant + HEnDehors test) to understand the underlying mechanism. Finally, he forbids himself from filling a memory table by traversing an entire large file: on large volumes, he prefers the file table with a filter and queries rather than a loop processing each record one by one.

Self-contained case for this section: it returns in the course, diagram, script and 48h challenge of section 2.4.

1. Two forms of traversal

After handling one record, you process sets. Traversal reviews the records of a file or a query. (1) The POUR TOUT loop: the modern and recommended form, concise and readable — it automatically traverses all records and handles the end of the traversal. (2) The manual loop with HLitPremier then HLitSuivant, testing HEnDehors to know when to stop: more verbose but essential to understand. In both cases, you can traverse according to an order (a key/index) and with a filter.

2. File table or memory table

The Table control is the natural companion of traversal: it displays several records in rows and columns. (1) The file table (known as “on file/query”) is linked to a data source and fills automatically; WinDev loads only the rows needed for display, which makes it performant even on very large volumes — the mode to favour in management applications. (2) The memory table is filled by code (TableAjouteLigne): total freedom but loading to manage — reserve it for constructed data or controlled volumes.

3. Performance vigilance

On large volumes, do not load everything into memory: prefer the file table with a filter. And for batch processing, favour queries or set-based functions rather than a loop processing a million records one by one. The classic trap — filling a memory table by traversing an entire large file — shows up mainly in production, when the real data arrives.

Common misinterpretation: “The memory table is always faster; a file table cannot be sorted; and POUR TOUT is just a shorter way of writing manual traversal”. No, three mistakes. The file table loads only the displayed rows and remains performant on large volumes, whereas the memory table loads everything; it is therefore often faster for large data sets coming from the database. A file table can be sorted perfectly (order of the source). Finally, POUR TOUT is the recommended form that automatically manages progression and the end of the traversal, distinct from manual traversal. Yacine therefore favours the file table on database data.
Traversing and displaying: two choices Traversal processes sets; the table displays by choosing file (automatic) or memory (by code). POUR TOUTModern traversal, handles the end+Manual traversalHLitPremier / HLitSuivant + HEnDehors+File tableLinked to file/query, displayed rows+Memory tableFilled by code (TableAjouteLigne) On large volumes: file table + filter, do not load everything into memory.
Traversal processes sets; the table displays by choosing file (automatic) or memory (by code).
Text version of the diagram (SEO / screen readers / translation): 1) Yacine, a WinDev developer at an SME trading electrical equipment in Oran, learns that traversal reviews the records of a file or a query, with two forms: the POUR TOUT loop (modern, recommended) and manual traversal (HLitPremier / HLitSuivant + HEnDehors test). 2) He remembers that the Table control displays records, that the file table linked to a file or query fills automatically while loading only the displayed rows, and that the memory table is filled by code with TableAjouteLigne. 3) For his catalogue, he displays a file table based on a filtered query, uses POUR TOUT to calculate stock alerts, and avoids loading everything into memory. Lesson: favour the file table on database data and queries for batch processing.

🔎 Concrete example — 🔎 Concrete example — POUR TOUT vs manual traversal

Two ways of writing the same traversal: Yacine identifies the products to restock.

// Recommended form: POUR TOUT
POUR TOUT Produit
    SI Produit.Stock < 5 ALORS
        TableAjouteLigne(TABLE_Alerte, Produit.CodeProduit, Produit.Stock)
    FIN
FIN

// Manual form (understand the mechanism)
HLitPremier(Produit, hOrdreCroissant, "CodeProduit")
TANTQUE HEnDehors(Produit) = Faux
    // ... process Produit ...
    HLitSuivant(Produit)
FIN

Reading   : POUR TOUT handles progression and the end; the manual form shows the mechanism
Reflex    : FILE table for display, do not load everything into memory

Reading: POUR TOUT traverses all records and stops by itself; manual traversal makes HLitPremier / HLitSuivant and the HEnDehors test explicit.

Lesson: for display, prefer a file table linked to a query rather than loading everything into memory.

Section vocabulary

Traversal
Reviewing the records of a file or a query, possibly according to an order (a key) and with a filter.

Simple example: Yacine traverses the Produit file to identify low stock.

What it is not: reading a single record identified by its key.

Reflex: process a set of records → a traversal.

POUR TOUT
The modern and recommended form of traversal: concise, readable, it automatically manages progression and the end of the traversal.

Simple example: Yacine writes POUR TOUT Produit to calculate alerts.

What it is not: a manual loop with HLitPremier / HLitSuivant.

Reflex: simple and readable traversal → POUR TOUT.

Manual traversal
The classic form: HLitPremier then HLitSuivant, testing HEnDehors to detect the end.

Simple example: Yacine writes the manual version to understand the mechanism.

What it is not: the POUR TOUT loop, which hides these steps.

Reflex: see what really happens → manual traversal.

File table
A table control linked directly to a file or a query: automatic filling, WinDev loads only the displayed rows.

Simple example: Yacine displays his catalogue in a file table based on a query.

What it is not: a table filled line by line by code.

Reflex: display large volumes → file table.

Memory table
A table control filled by code (TableAjouteLigne): total freedom but loading to manage yourself.

Simple example: Yacine fills a memory table with only the products in alert.

What it is not: a table linked to a database query.

Reflex: data constructed by code → memory table.

In practice — In practice — Traversing and displaying records

  1. Write a traversal with POUR TOUT (recommended form) to process all the records of a file or a query, like Yacine.
  2. Write the same traversal in manual form (HLitPremier / HLitSuivant + HEnDehors test) to understand the underlying mechanism.
  3. For display, preferably use a file table linked to a file or a query: it fills automatically and remains performant on large volumes.
  4. Reserve the memory table (TableAjouteLigne) for data constructed by code, and on large volumes filter rather than loading everything.
You know how to traverse sets of records in code and display them efficiently, choosing the right table type according to volume and data origin.

Step-by-step script — traverse the catalogue like Yacine (5 min)

1) Create a file table linked to a filtered Produit query (stock < threshold). 2) Write a POUR TOUT Produit traversal that tests Produit.Stock. 3) Add the products in alert to a memory table via TableAjouteLigne. 4) Rewrite the traversal in manual form (HLitPremier / HLitSuivant + HEnDehors) to analyse it. 5) On a large volume, check that you are not loading everything into memory.

Default reflex in management applications: as soon as the data comes from the database, use a file table based on a query.

Copy-paste template — my traversal & my table

POUR TOUT traversal: POUR TOUT Produit ... FIN   (recommended)
Manual traversal   : HLitPremier(...) ; TANTQUE HEnDehors(...) = Faux ... HLitSuivant(...) ; FIN
FILE table         : linked to a file/query, AUTO fill, displayed rows
MEMORY table       : filled by CODE (TableAjouteLigne)
Rules : (1) display from database -> FILE table
        (2) large batch processing -> QUERIES, not a row-by-row loop

POUR TOUT traversal

Yacine traverses the whole Produit file to recalculate stock alerts.

Manual traversal

Yacine writes the HLitPremier / HLitSuivant version to understand the flow.

File table

Yacine displays the catalogue via a table linked to a query, loaded on demand.

Memory table

Yacine fills a small table of only the out-of-stock products by code.

✓ Best practices

  • Use POUR TOUT by default, and know manual traversal.
  • Display database data with a file table linked to a query.
  • Do not load everything into memory on large volumes.

✗ Common pitfalls

  • Filling a memory table by traversing a large file.
  • Believing that a file table cannot be sorted.
  • Processing a million records one by one rather than with a query.

Key takeaways

  • Two forms of traversal: POUR TOUT (recommended) and manual traversal (HLitPremier / HLitSuivant + HEnDehors).
  • The Table control displays records; the file table is linked to a file/query and loads only the displayed rows.
  • The memory table is filled by code (TableAjouteLigne) — reserve it for constructed data.
  • On large volumes: file table + filter; batch processing via queries.

48h challenge — apply it tomorrow

Like Yacine, write a POUR TOUT traversal on a file in your application, then rewrite it in manual form (HLitPremier / HLitSuivant + HEnDehors test). Then display that data in a file table linked to a query and check that it loads only the visible rows. Explain in one sentence why you must not fill a memory table by traversing an entire large file.

Section exit checklist
  • I know how to write a traversal with POUR TOUT and in manual form.
  • I choose between file table and memory table according to the origin and volume of the data.
  • I know how not to load everything into memory on large volumes.
Self-assessment 1-5: do I distinguish POUR TOUT and manual traversal?Self-assessment 1-5: do I know when to use a file table rather than a memory table?

Frequently asked questions

What is the difference between a file table and a memory table?

The file table is linked to a file or a query and loads only the displayed rows: it is performant even on very large volumes. The memory table is filled by code and loads everything into memory: total freedom but unsuitable for large volumes. In management applications, the file table is therefore preferred.

Why learn manual traversal when POUR TOUT exists?

Because it shows what really happens (moving from one record to the next, testing the end) and remains useful in special cases. POUR TOUT is the modern and recommended form for everyday use; understanding manual traversal helps diagnose tricky situations.

Check your understanding

What is the difference between a file table and a memory table?

Additional resources (optional, to go further)

Level 2 examFresh, harder questions to test what you've learned