table insert rows (if needed)

Prev Next

Function Names

table insert rows, table insert rows if needed

Description

This function inserts a specified number of blank rows in a specified location.

The suffix ... if needed will suppress an exception if the rows to be inserted lie below the last table row. In this case, no actions will happen. Not even blank rows are added below.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

2 - 3

Parameters

No.TypeDescription
1.
input
string Name of existing table

2
input
numeral Row number

Table rows begin with row 0 (header row). Negative indexing is supported, i.e. -1 = last table row.

3
input
numeral Number of rows to isert

Number of blank rows to insert.
Negative numbers are also supported: -1 counts the number aremaining rows (including the current one) and uses this value as number of rows to insert. For example if 3 rows are remaining, then 3 rows wil be inserted. -2 inserts 1 row less; -3 inserts 2 rows less, etc.

Default value: 1

Exceptions

Table not found

Examples

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

  table insert rows( table 1, 1, 2 );  // Insert 2 rws above row 1 (below header row)
  table insert rows( table 1, -1, 1 ); // Insert 1 row before last row

  table list( table 1 );

Output

    0 : Animal | leg count
    1 :        |          
    2 :        |          
    3 : Worm   | 0        
    4 : Bird   | 2        
    5 : Dog    | 4        
    6 : Fly    | 6        
    7 :        |          
    8 : Tick   | 8        

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

See also

table insert selected rows