table flip columns

Prev Next

Function Names

table flip columns

Description

This function flips (i.e. mirrors) the columns in the table. Either all columns below the existing header row (widht of header applies), or a specified range from one column till another column can be flipped. The header row will also be flipped. You are allowed to specify columns beyond the existing table contents in order to move blank columns to the left.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

1-3

Parameters

No.TypeDescription
1.
input
string Name of existing table

The columns in this table will be flipped

Opt. 2
input
table columns Starting column

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

  • Only one column number or header name may be specified.
  • If a column number is specified, then it may be beyond the header row or bigger than the number of existing columns in the table.

Opt. 3
input
table columns Ending column

Flipping ends at this column. No flips made if ending column is before the starting column.
See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • Only one column number or header name may be specified.
  • If a column number is specified, then it may be beyond the header row or bigger than the number of existing columns in the table.

Examples

       table initialize( temps,
        { { City,     Winter, Spring, Summer, Autumn  },
          { Stockholm,    -5,      5,     15,     10  },
          { Munich,        5,     10,     25,     15  },
          { Rome,         10,     20,     35,     25  },
          { Nairobi,      25,     25,     25,     25  } });

       table list ( temps );

       // Flip the seasons including 1 blank column to the right to add space

       table flip columns ( temps, Winter, 5 );
       echo("Columns flipped:");
       table list ( temps );

Output

    0 : City      | Winter | Spring | Summer | Autumn
    1 : Stockholm | -5     | 5      | 15     | 10    
    2 : Munich    | 5      | 10     | 25     | 15    
    3 : Rome      | 10     | 20     | 35     | 25    
    4 : Nairobi   | 25     | 25     | 25     | 25    

Columns flipped:
    0 : City      |  | Autumn | Summer | Spring | Winter
    1 : Stockholm |  | 10     | 15     | 5      | -5    
    2 : Munich    |  | 15     | 25     | 10     | 5     
    3 : Rome      |  | 25     | 35     | 20     | 10    
    4 : Nairobi   |  | 25     | 25     | 25     | 25    

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

See also

table flip rows
table flip vertically
table transpose