for all table selected columns

Prev Next

Function Names

for all table selected columns

Synopsis

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

Description

The loops works through selected columns (where comparisons do match) 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

2-6

Parameters

No.TypeDescription
1
input
string table name

Name of existing table

2
code
comparison expression
:string
comparison expression

This expression is applied to compare the column header names, regardless of row number specified in the 2nd parameter. The checking is done once before the loop starts. The loop behavior will not be affected if the header names are changed afterwards, for example renamed. Attention to inserting and deleting columns: The loop has memorized the actual column numbers (which will not change) and not the header names.

Attention: To avoid hijacking further function parameters as additional values to be compared, put the expression into parentheses if no operators, = or <> have been used. Not an issue if <, >, == or != operators are used.

Default value: 0
Opt. 3
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.

Opt. 4
code
variable
:string
iterator column number

This value refers to the current column number

Opt. 5
code
variable
:string
iterator header name

This value refers to the current column header name

Opt. 6
code
variable
:string
iterator counter

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( animals,
               {{ Name, Class, Number of Legs,Surface},
                { Dog, Mammal, 4, Hair }, { Snake, Reptile, 0, Skin }, { Parrot, Bird, 2, Feathers }} );

       // Choose all columns with headers containing 's'. The list results for row 2.

       for all table selected columns( animals, ('*s*'), 2, column[], header[], i[] ) // Leg count skipped
       {
               echo( i[],": Column ", column[], " (", header[], ") = ", [column[]] );
       }

       echo;

       for all table selected columns( animals, ('*s*'), 2, column[]) // Leg count skipped
       {
               echo( "Column ", column[], " (", [.,0], ") = ", [.] );
       }

       echo;

       for all table selected columns( animals, ('*s*') ) // Leg count skipped
       {
               echo( " (", [.], ") = ", [.,2] );
       }

Output

0: Column 1 (Class) = Reptile
1: Column 2 (Number of Legs) = 0

Column 1 (Class) = Reptile
Column 2 (Number of Legs) = 0

(Class) = Reptile
(Number of Legs) = 0
Try it yourself: Open LIB_Function_for_all_table_selected_columns.b4p in B4P_Examples.zip. Decompress before use.

See also

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