for all table columns

Prev Next

Function Names

for all table columns

Synopsis

for all table columns ( table name, reference row number, iterator value, iterator counter ) statement;
for all table columns ( table name, reference row number, iterator value, iterator counter ) {statements; }

Description

The loops works through all columns in the table specified and executes the following statements specified.

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 existing table

Opt. 2
input
numeral reference row number

Positive values must be between 0 and number of table rows minus 1.

Negative values allow addressing the last row upwards: -1 = last row, -2 = next row above. The negative number must not be smaller than the negated number of rows.

Default value: 0
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 interator value can also be referenced using partial table specifications [.], meaning specified row and current column from the table context. Here, the 'quoted string' rule specified above does not apply.

Opt. 4
code
variable
:string
iterator counter

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.

Examples

       table initialize( animals,
               {{ Name, Class, Number of Legs},
                { Dog, Mammal, 4 }, { Snake, Reptile, 0 }, { Human, Mammal, 2 }} );

       for all table columns( animals, 2, value[], i[] )
       {
               echo( i[],". ", [i[],0], ": ", value[] );
       }

       echo; // You can also use the current column number known in the partial table context:
                 // [.] = Current table, column and row.  [.,0] = Current table, column and row 0
                 // Also allowed: ['.'], ['<.'] where then 2nd one refers 1 column to the left.

       for all table columns( animals, 2 ) // A bit simpler
       {
               echo( [.,0], ": ", [.] );
       }

       echo;

       for all table columns( animals ) // Same output as above (row 0 assumed as default)
       {
               echo( [.], ": ", [.,2] );
       }

Output

0. Name: Snake
1. Class: Reptile
2. Number of Legs: 0

Name: Snake
Class: Reptile
Number of Legs: 0

Name: Snake
Class: Reptile
Number of Legs: 0
Try it yourself: Open LIB_Function_for_all_table_columns.b4p in B4P_Examples.zip. Decompress before use.

See also

for all current table columns
for all table selected columns
for all current table selected columns