table row width

Prev Next

Function Names

table row width

Description

This table returns the width of a specific table row.
If a table context for partial table specifications is available, then the current table name and optionally current row number can be used as default values.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

0-2

Parameters

No.TypeDescription
Opt. 1
input
string name of table

Specify the table name

Default value: If a __table context__ is available: current table name
1 / 2
input
numeral row number

Note that the first table row (header row) begins with row 0. Negative row numbers count from the bottom up. Example: -1 = last row.

Default value: If a __table context__ is available: current table row

Return value

TypeDescription
numeral Width

Number of columns in the row. If specified row lies beyond the end of the table, -1 is returned.

Exceptions

Table not found
No context available for partial table specifications

Examples

       table initialize ( table 1,
       { { Animal, leg count, hair color }, { Worm,  0}, { Bird, 2, white, brown, yellow }, { Dog, 4 }, { Fly }, {}, { Tick, 8 } } );

       echo("table 1:");
       table list ( table 1 );

       print( table row width( table 1, 1 ),", " );          // 2 (2nd row)
       print( table row width( table 1  ),  ", " );          // 3 (row 0)
       echo ( table row width( table 1, -2 ) );                // 0 (2nd last row)
       with table (table 1, 1)
       {
               print( table row width( 2 )); // 5 (Row 3)
               echo( ", ", table row width(  )); // 2 (Row 1)
       }

Output

table 1:
    0 : Animal | leg count | hair color |       |       
    1 : Worm   | 0         |            |       |       
    2 : Bird   | 2         | white      | brown | yellow
    3 : Dog    | 4         |            |       |       
    4 : Fly    |           |            |       |       
    5 :        |           |            |       |       
    6 : Tick   | 8         |            |       |       

2, 3, 0
5, 2
Try it yourself: Open LIB_Function_table_row_width.b4p in B4P_Examples.zip. Decompress before use.

See also

table min width
table max width