table selected rows

Prev Next

Function Names

table selected rows, table all selected rows

Description

This function obtains the row numbers of the selected rows and returns them as a set containing numerals. Row 0 (header row) is not checked. This function is very useful for searching contents in known columns and retrieving all matches.

The all in the function name includes row 0 in the selection process. Otherwise it begins at row 1.

Call as: function

Restrictions

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

Parameter count

2

Parameters

No.TypeDescription
1.
input
string Name of existing table

2.
code
expression
:string
Expression to select rows

Applicable to function table copy columns selected rows only. Specify the conditions or rules to select the rows. See expressions to select rows.
The table context for partial table specifications is available for referencing just the columns easily. Example: [Year]>=2022.
Attention: Comparison operators = and <> (instead of == and !=) may hijack the next function parameters for its own use as additional comparison operands, e.g. a[]=1,3,5. As long this comparison is not made in the last function parameter, then put parentheses around them, e.g. ... , (a[]=1,3,5), ....

Return value

TypeDescription
set Retrieved row numbers

The set contains numerals. An empty set is returned if there are no matches.

Examples

       table initialize ( table 1, { { Animal, leg count },
               { Worm,  0}, { Bird, 2 }, { Dog, 4 }, { Fly, 6 }, { Tick, 8 } } );

       echo( table selected rows( table 1, mod( [leg count], 4 ) = 0 ) );
       // Leg countsa are 0, 4, 8, row numbers are 1, 3, 5.

       echo( table selected rows( table 1, ([Animal]='B*','D*') ) );
       // Returns rows 2 and 3.

Output

{1,3,5}
{2,3}
Try it yourself: Open LIB_Function_table_selected_rows.b4p in B4P_Examples.zip. Decompress before use.

See also

table read column selected rows
table search row
table selected columns