table selected columns/headers ...

Prev Next

Function Names

table selected columns, table selected column numbers, table selected headers

Description

This function searches the contents in one specified table row and returns the following:
With table selected columns: Actual values in the columns where the matches are successful
With table selected column numbers: The column numbers where where the matches are successful
With table selected column numbers: The corresponding header names of the columns where matches are successful

Attention: All values from the table being compared are strings, even if they contain numbers.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

2-4

Parameters

No.TypeDescription
1.
input
string Name of existing table

2.
code
comparison expression
:string
Value compared with the table contents

This parameter is a piece of code typically found on the right-hand side of a comparison with '=' or '<>'. Single values, ranges (e.g. 3..5), multiple values separated by commas are supported. For text comparison, wildcards are supported if the string is of type softquoted string.

Opt. 3.
input
numeral Row number

Specifies the row number where to carry out the comparisons

Default value: 0
Opt. 4
input
table column Existing column

See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • Specify one header name or column number to indicate where to start searching and comparing frmo left to right.

Default value: 0 (1st column)

Return value

TypeDescription
set Retrieved values

Contains strings or numerals, depending on the function name used.

Examples

       table initialize( table 1,
               { { Last Name, 1st Name, Street, Town, Postal Code, "Spouse's Name", Zip Code },
                 { Miller,    Phil,     Main St., Denver, 80208, Ann, 80123 } } );

       echo( table selected columns( table 1, '*Code' ) );

       // If the comparison expression is not the last function parameter, then put it into
       // parentheses to avoidi including further parameters used in the comparison process.

       echo( table selected columns( table 1, (=80208), 1 ) );
       echo( table selected headers( table 1, ( '80*' ), 1 ) );
       echo( table selected column numbers( table 1, ( '80*' ), 1, 5 ) ); // Column 4 skipped

Output

{'Postal Code','Zip Code'}
{80208}
{'Postal Code','Zip Code'}
{6}
Try it yourself: Open LIB_Function_table_selected_columns.b4p in B4P_Examples.zip. Decompress before use.

See also

table selected rows