table insert cells in columns

Prev Next

Function Names

table insert cells in columns

Description

In a specified row, cells in specified columns will be insersted where the contents below will shift down.

Call as: procedure or function

Restrictions

Indirect parameter passing is disabled

Parameter count

3-4

Parameters

No.TypeDescription
1.
input
string Name of existing table

2
input
table columns Header names and/or column numbers

Only the cells in the specified columns will be insesrted. 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

3.
input
numeral Row number

Starting row number where cells in specified columns (and below) will be inserted

Opt. 4.
input
string Count

Number of cells to insert (with contents below shifting down accordingly)
Negative indexing is supported, i.e. -1 removes all cells below, -2 removes all cells except the cell in the last row (which will move up accordingly), etc.

Default value: 1

Return value

TypeDescription
numeral Number of columns processed

Counts all columns selected where cells have been inserted.

Examples

       table initialize ( t,
         { { Nr,  A,  B,  C,  D,  E  },
                       {  1,  A1, B1, C1, D1, E1, F1, G1 },
                       {  2,  A2, B2, C2, D2, E2, F2, G2 },
                       {  3,  A3, B3, C3, D3, E3 },
                       {  4,  A4, B4, C4, D4, E4, F4, G4 },
                       {  5,  A5, B5, C5, D5, E5, F5, G5 } } );


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

       echo("2 cells inserted in columns A, B, C, D, E and column 7.");
       a[] = table insert cells in columns( t, {A..C,E,7}, 2, 2, ".." );
       table list ( t );
       echo("Number of columns affected: ", a[]);

Output

Original table:
    0 : Nr | A  | B  | C  | D  | E  |    |   
    1 : 1  | A1 | B1 | C1 | D1 | E1 | F1 | G1
    2 : 2  | A2 | B2 | C2 | D2 | E2 | F2 | G2
    3 : 3  | A3 | B3 | C3 | D3 | E3 |    |   
    4 : 4  | A4 | B4 | C4 | D4 | E4 | F4 | G4
    5 : 5  | A5 | B5 | C5 | D5 | E5 | F5 | G5

2 cells inserted in columns A, B, C, D, E and column 7.
    0 : Nr | A  | B  | C  | D  | E  |    |   
    1 : 1  | A1 | B1 | C1 | D1 | E1 | F1 | G1
    2 : 2  | .. | .. | .. | D2 | .. | F2 | ..
    3 : 3  | .. | .. | .. | D3 | .. |    | ..
    4 : 4  | A2 | B2 | C2 | D4 | E2 | F4 | G2
    5 : 5  | A3 | B3 | C3 | D5 | E3 | F5 |   
    6 :    | A4 | B4 | C4 |    | E4 |    | G4
    7 :    | A5 | B5 | C5 |    | E5 |    | G5

Number of columns affected: 5
Try it yourself: Open LIB_Function_table_insert_cells_in_columns.b4p in B4P_Examples.zip. Decompress before use.

See also

table delete cells in columns
table insert cells selected rows