table delete rows (if needed)

Prev Next

Function Names

table delete rows, table delete rows if needed

Description

This function deletes a specified number of rows in a specified location.

The suffix ... if needed will suppress an exception if the rows to be deleted lie below the last table row. In this case, no actions will happen.

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 delete

Number of rows to delete.
Negative numbers are also supported: -1 deletes all remaining rows. -2 deletes all remaining rows except the last row, -3 keeps the last two rows, 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 delete rows( table 1, 1, 2 );  // Deltess Worm and Bird
       table delete rows( table 1, -1, 1 ); // Deletes Tick

       table list( table 1 ); // Only Dog and Fly are left

Output

    0 : Animal | leg count
    1 : Dog    | 4        
    2 : Fly    | 6        

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

See also

table delete remaining rows
table delete selected rows