table write column selected rows

Prev Next

Function Names

table write column selected rows

Description

This function writes values in a parameter set vertically into a specified table column where the rows are chosen with a boolean expression. The write operation ends if either one of the two criteria are met:

  • The last element in the parameter set has been written
  • The end of the table has been reached. The table will not be extended with additional rows in case the parameter set contains more elements than the number of matching rows.

Call as: procedure or function

Restrictions

Indirect parameter passing is disabled
This function provides a table context for partial table specifications with table name and row number for selected function parameters

Parameter count

4

Parameters

No.TypeDescription
1.
input
string Name of existing table

2.
input
table column Existing column

See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • Only 1 header name or column number may be specified.

3.
code
expression
:string
Expression to select rows

Specify the conditions or rules to select the rows. See expressions to select rows.
The table context for partial table specifications is available for referencing just the columns easily. Example: [Year]>=2022.
Attention: Comparison operators = and <> (instead of == and !=) may hijack the next function parameters for its own use as additional comparison operands, e.g. a[]=1,3,5. As long this comparison is not made in the last function parameter, then put parentheses around them, e.g. ... , (a[]=1,3,5), ....

4.
input
parameter set Contents to write

The elements in the parameter set will be written into the appicable rows.

Return value

TypeDescription
boolean Feedback

true if operation was successful, and false if not.

Examples

  include( Support Library ); // for 'table list' function
  table initialize ( table 1, { { Animal, leg count },
      { Worm,  0}, { Bird, 2 }, { Dog, 4 }, { Fly, 6 }, { Tick, 8 } } );

  [table 1:2,0] = size;
  table write column selected rows( table 1, size, ([Animal]=Dog,Bird), { Not small, Big, Tiny } );
  // Note: 'Tiny' will not be written.

  table list( table 1 );

Output

    0 : Animal | leg count | size     
    1 : Worm   | 0         |          
    2 : Bird   | 2         | Not small
    3 : Dog    | 4         | Big      
    4 : Fly    | 6         |          
    5 : Tick   | 8         |          

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

See also

table read column selected rows