table add row, table write row

Prev Next

Function Names

table add row, table write row

Description

These simple functions write data into a table where the row number, header names and correponding values are specified. The function call may be extended with additional parameters in order to write the rows below, too.

table write row writes the data at the specified row number.
table add row adds the data below the last line of the table.

Call as: procedure or function

Restrictions

Indirect parameter passing is disabled

Parameter count

Min 3 (table add row) / Min 4 (table write row)

Parameters

No.TypeDescription
1.
input
string name of new or existing table

Table must be existing when using table append... functions. Otherwise, it does not matter.

2.
input
table columns Header names and/or column numbers

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
  • Nonexisting header names will be added to the table

3.
input
numeral Starting row number

This parameter applies to table write row only. It refers to the starting row number where to write the data.
For the function, table add row, the next row below the table is assumed and therefore this parameter is skipped. Negative indexing is supported.

Default value:
3. / 4., etc.
input
set Data to add or write

All data written to the table must be put into set and passed in this function parameter, even if only one string value is provided. The number of elements must not exceed the number of table columns specified but may be lower. If fewer data elements are specified, then the remaining fields will not be overwritten.

Void values will not be written into the table. You can actually use void values in order to prevent updating specific fields.

Return value

TypeDescription
numeral Number of rows written

Returns the number of rows written.

Examples


       table initialize ( t,
       { { Animal, leg count, size,         intelligence },
         { Worm,   0,         very small,   low},
         { Fox,    4,         quite small,  medium } });

       table write row( t, { size, Animal, leg count, skin }, 1, { tiny, null(), no legs }, { null(), Dog, four, haired } );
       table add row  ( t, { Animal, size, intelligence }, { Ape, quite big, smart }, { Jellyfish, small } );

       table list ( t );

Output

    0 : Animal    | leg count | size        | intelligence | skin  
    1 : Worm      | no legs   | tiny        | low          |       
    2 : Dog       | four      | quite small | medium       | haired
    3 : Ape       |           | quite big   | smart        |       
    4 : Jellyfish |           | small       |              |       

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

See also

table read row
table append
table add missing row