col

Prev Next

Function Names

col

Description

This function returns the current column number as provided in the table context for partial table specifications. It is useful to access neighboring row numbers in the same table, for example row()-1 for the row above the current row.

In case nested (i.e. multiple overlaying) table contexts are available, then the the number of levels up can be specified in the function parameter to obtain the row number of one of the outer table contexts.

Attention: This function will assert an exception (error message) if the table context is not available, or the depth value is too high, or the table context does not contain a column numer.

Call as: function

Restrictions

Indirect parameter passing is disabled
context for partial table specifications is required

Parameter count

0-1

Parameters

No.TypeDescription
1
input
numeral Depth

Specifies the depth in case nested partial table specifications is activated. 0 refers to the current table, 1 and bigger values to superior tables. 0 is assumed if no parameter is specified.

Default value: 0 (innermost table context)

Return value

TypeDescription
numeral Column number

Examples

       table initialize( animals,
               {{ Name, Class, Number of Legs,Surface},
                { Dog, Mammal, 4, Hair }, { Snake, Reptile, 0, Skin }, { Parrot, Bird, 2, Feathers }} );

       // The simplified approach: [.] = current table, row and column. [.,0] = current table, column, and row 0

       with table ( animals, 2 )
       {
               for all current table selected columns('*s*')
               {
                       echo( col(), ": Column (", [.,0], ") = ", [.] );
               }
       }

Output

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

See also

row
with table
partial table specifications