table split table columns ...

Prev Next

Function Names

table split table columns

Description

This function moves selected columns from the existing to a new table..
The function table copy table columns selected rows copies only the selected rows instead of all rows. If the new table is already existing, then it will be initialized.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

3-4

Parameters

No.TypeDescription
1.
input
string Name of existing table

2.
input
string Name of new table

3.
input
table columns Columns to spit

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

  • Any number of header names and column numbers may be specified
  • Every column specified must be unique, i.e. no multiple references to the same column

Opt 4.
input
table columns Columns to copy

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

  • Any number of header names and column numbers may be specified
  • Columns also mentioned in the 3rd function parameter will be considered to be split, i.e. splitting overrules copying.

Examples

       table initialize( t, {{ Name, Age, Hobby, Favorite Color },
               { Ann, 45, Skiing, Blue }, { Dan, 35, Skating, Orange },
               { Eva, 40, Bee keeping, Yellow }, { Nic, 10, Reading, Green } } );

       echo("Original table:");
       table list( t );

       echo("Split out Hobby, copy Name and Favorite Color:");
       table split table columns ( t, u, {Hobby, Favorite Color}, {Name, Favorite Color} );
       table list( u );

       echo("Original table contains Name and Age.");
       table list( t );

Output

Original table:
    0 : Name | Age | Hobby       | Favorite Color
    1 : Ann  | 45  | Skiing      | Blue          
    2 : Dan  | 35  | Skating     | Orange        
    3 : Eva  | 40  | Bee keeping | Yellow        
    4 : Nic  | 10  | Reading     | Green         

Split out Hobby, copy Name and Favorite Color:
    0 : Name | Favorite Color | Hobby      
    1 : Ann  | Blue           | Skiing     
    2 : Dan  | Orange         | Skating    
    3 : Eva  | Yellow         | Bee keeping
    4 : Nic  | Green          | Reading    

Original table contains Name and Age.
    0 : Name | Age
    1 : Ann  | 45
    2 : Dan  | 35
    3 : Eva  | 40
    4 : Nic  | 10

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

See also

table split table selected rows
table copy table