table flip selected rows

Prev Next

Function Names

table flip selected rows

Description

This function flips (i.e. mirrors) selected rows in the table

Call as: procedure or 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 - 4

Parameters

No.TypeDescription
1.
input
string Name of existing table

2.
code
expression
:string
Expression to select rows

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
numeral Number of rows deleted

Number of rows deleted. -1 is returned if table is empty.

Examples

       table initialize( t,
                { { Last Name,   First Name, Age },
                  { Andersen,    Anders,       30 },
                  { Donaldson,   Donald,       20 },
                  { Johansson,   John,         40 },
                  { Poulsen,     Paul,         50 },
                  { Svensson,    Sven,         10 } } );

       echo("Before flipping:");
       table list ( t );
       a[] = table flip selected rows ( t, [Age]>=30 );
       echo("Rows flipped: ", a[]);
       table list ( t );

Output

Before flipping:
    0 : Last Name | First Name | Age
    1 : Andersen  | Anders     | 30
    2 : Donaldson | Donald     | 20
    3 : Johansson | John       | 40
    4 : Poulsen   | Paul       | 50
    5 : Svensson  | Sven       | 10

Rows flipped: 1
    0 : Last Name | First Name | Age
    1 : Poulsen   | Paul       | 50
    2 : Donaldson | Donald     | 20
    3 : Johansson | John       | 40
    4 : Andersen  | Anders     | 30
    5 : Svensson  | Sven       | 10

Try it yourself: Open LIB_Function_table_flip_selected_rows.b4p in B4P_Examples.zip. Decompress before use.

See also

table flip rows
table flip vertically
table flip columns
table transpose