for all table rows

Prev Next

Function Names

for all table rows

Synopsis

for all table rows ( table name, reference column, iterator value, iterator counter ) statement;
for all table rows ( table name, reference column, iterator value, iterator counter ) {statements; }

Description

This loop works through all rows in the table except the header row and executes the subsequent statements or block.

Call as: procedure

Restrictions

Indirect parameter passing is disabled
This function provides a table context for partial table specifications with table name, row number and column number

Parameter count

1-4

Parameters

No.TypeDescription
1.
input
string Table Name

Name of exsting table

Opt. 2.
input
table columns Reference Column

Specify 1 column header name or 1 column number. This column will be used to count the rows in the table and return the iterator value from every row.

Opt. 3
code
variable
:string
iterator value

This variable is updated by this function in order to provide the current value taken from the specified table column and referenced row. The variable is always of type 'quoted string', even if containing numbers or dates. You need to convert the type by hand if needed.

Opt. 4
code
variable
:string
iterator counter

Equivalent to current row number while working throuh the table. This variable is updated by this function and provdes the index. It always begins with 0 and continues with 1, 2, etc.

Examples

      table initialize ( colors, { { EN, FR }, { red, rouge }, { blue, blue }, { green, vert }, { rose, rosé }, { yellow, jaune } } );

      // Simple case with 1 parameters
      for all table rows( colors )
      {
          echo( [EN], " -> ", [FR] ); // All French colors ending with 'e'
      }

      // All 4 parameters
      // Note the extra parentheses for 2nd parameter to avoid hijacking further function parameters into the comparison
      for all table rows( colors, EN, value[], index[] )
      //
      {
          echo( "index ", index[], ": ",value[], " -> ", [FR] ); // All French colors ending with 'e'
      }

Output

red -> rouge
blue -> blue
green -> vert
rose -> rosé
yellow -> jaune
index 1: red -> rouge
index 2: blue -> blue
index 3: green -> vert
index 4: rose -> rosé
index 5: yellow -> jaune
Try it yourself: Open LIB_Function_for_all_table_rows.b4p in B4P_Examples.zip. Decompress before use.

See also

table process
for all table columns