table process cells in columns (selected rows)

Prev Next

Function Names

table process cells in columns, table process cells in columns selected rows

Description

These functions are derivatives of table process cells() and table process cells selected rows() with the only difference that an additiona function parameter specifies the columns to be processed. All other columns remain untouched. As an example, this function is suitable for processing a table containing many columns with dates and you want to use one single statement to reschedule or reformat all dates.

For this function, the enabled partial table specifications also includes referencing the current column number by simply specifying a '.' (point) and you can use the function col() to retrieve the current column number.

This feature allows simple formulation of instructions without writinng a 2-dimensional loop. The closest relative of this function is the combination of for all table rows() and for all table selected columns() which describe two nested loops.

Note: The statements will be applied on all rows underneath the specified columns, even if some table rows are shorter than the column positions used.

Call as: procedure or function

Restrictions

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

Parameter count

3-5

Parameters

No.TypeDescription
1.
input
string Name of existing table

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

This parameter specifies the columns which shall be processed with the statements provided in the following parameter(s). All other columns remain unaffected. Nothing will be executed if no columns are specified.

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

  • Any number of existing header names and column numbers may be specified

Opt. 3.
code
expression
:string
Expression to select rows

Applicable to table process selected rows only:
Specify the conditions or rules to select the rows. See expressions to select rows. It will be calculated only once per row (and not for every cell).
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), ....

3. / 4.
code
statements
:string
Statements (applicable where rows are selected)

table process cells: The statements provided will be executed for every row.
table process cells selected rows: The statements provided will be executed for every row where the condition calculated before returned true.

The table context for partial table specifications is available for referencing just the columns easily. Example: [Full Name]=[First Name]+' '+[Last Name];.
Hint: If you encounter an error message at the very end of the program after you worked on a statement, you may proabably have forgotton to add the closing parentheses to close the function call.

5.
code
statements
:string
Statements (otherwise)

table process cells: Not applicable. This function accepts 3 parameters only. table process cells selected rows: The statements provided will be executed for every cell in every row where the condition calculated for that row returned false.

The table context for partial table specifications is available for referencing just the columns easily. Example: [Full Name]=[First Name]+' '+[Last Name];.
Hint: If you encounter an error message at the very end of the program after you worked on a statement, you may proabably have forgotton to add the closing parentheses to close the function call.

Return value

TypeDescription
numeral Number of cells processed

With table process selected rows, the number of selected rows (and processed with statements from 3rd function parameter) are counted.

Examples

  table initialize ( animals, { {Animal, Group, Special abilities},
      { parakeet, bird, can fly },  { moose, mammal },  { ape, mammal, quite samrt },  { sparrow, bird } , { trout, fish }, { bass, fish },
      { canary, bird }, { penguin, bird }, { beluga, mammal, submarine sonar} } );

  table process cells in columns               ( animals, { Group, Special abilities},   [.] += '!' );    // 2 named columns affected
  table process cells in columns selected rows ( animals, { 0, -1 }, [Group]=='mammal!', [.] = +[.] );    // 1st and last column affected, mammals only

  table list ( animals );

Output

    0 : Animal   | Group   | Special abilities
    1 : parakeet | bird!   | can fly!         
    2 : MOOSE    | mammal! | !                
    3 : APE      | mammal! | QUITE SAMRT!     
    4 : sparrow  | bird!   | !                
    5 : trout    | fish!   | !                
    6 : bass     | fish!   | !                
    7 : canary   | bird!   | !                
    8 : penguin  | bird!   | !                
    9 : BELUGA   | mammal! | SUBMARINE SONAR!

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

See also

table process cells
table process cells selected rows