table read row

Prev Next

Function Names

table read row

Description

These simple functions reads data from a table where the row number and the header names are specified. Type conversions rules apply according to the settings done with table configure(). By default, numbers will be read as numbers.

The function call table read row( table name, { Name, Phone }, 5 ); is equivalent to [ table name: { Name, Phone }, 5 ].

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

3

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

3.
input
numeral Row number

Negative indexing is supported. Accessing empty rows or rows below the table end return blank contents in the parameter set.

Default value:

Return value

TypeDescription
parameter set data read

The parameter set contains the data read in the order of the headers and columns are specified, even if only one header name is specified.

Examples

  table initialize ( t,
  { { City,  Country, Climate Zone, Average Temperature },
    { Rome,  Italy,        Mediterranean,  22.3  },
    { Medina, S. Arabia,   Desert,  30  },
    { Thule, Greenland,    Arctic, -5 } } );

  echo( table read row ( t, { Country, City, 3, Climate Zone }, 1 ) ); // Rome
  echo( table read row ( t, { Country, City, 3, Climate Zone }, -1 ) ); // Last row: Thule
  echo( table read row ( t, { City, 24 }, 2 ) ); // Medina, and blank data (beyond last column)
  echo( table read row ( t, { Country, City, 3, Climate Zone }, 10 ) ); // Blank data (outside table)

Output

{'Italy','Rome',22.3,'Mediterranean'}
{'Greenland','Thule',-5,'Arctic'}
{'Medina',''}
{'','','',''}
Try it yourself: Open LIB_Function_table_read_row.b4p in B4P_Examples.zip. Decompress before use.

See also

table write row