table substitute vertically ...

Prev Next

Function Names

table substitute vertically, table substitute vertically selected rows

Description

These functions are the counterparts to table fill horizontally() and table fill horizontally selected rows(). Here, repetitions in rows will be replaced by blanks or substitute symbols of choice (e.g. ", see above, ditto, etc.)

Call as: procedure

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

2-5

Parameters

No.TypeDescription
1.
input
string Name of existing table

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

Applicable to table substitute vertically selected rows only:
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), ....

2. / 3.
input
table columns Columns to substitute

In these columns, rows with repeating contents will be substituted.
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

Opt. 3. / 4.
input
parameter set or string Substitution strings

If one string is provided, then it will be used to substitute fields in all specified columns. If more strings are provided in a parameter set, then they will correspond with the columns specified. If the parameter set contains fewer elements than the number of columns provided, then the last element will apply for the remaining columns. Otherwise, if this parameter set is longer, then the excess values will be ignored.
Good examples: '' (blank), '...', 'see above', etc.

Default value: '' (blank)
Opt. 4. / 5.
input
string Direction

Following values are supported: up and down for repeating contents in upward resp. downward direction.

Default value: down

Examples

  table initialize ( t, { {Name, Date, Tennis Scores},
       { Jim,   "2020-06-20", "6:5 6:2 6:3" },
       { Jim,   "2020-06-20", "7:6 6:4 5:6" },
       { Jim,   "2020-06-21", "6:2 5:6 4:6" },
       { Jane,  "2020-06-21", "5:4 6:5 7:6" },
       { Jane,  "2020-06-21", "3:6 7:6 6:5" } } );

  table copy table ( t, u );

  echo("Original table: ");
  table list( t );

  echo("Substitution downward:");
  table substitute vertically( t, {Name, Date}, { '"', '...' } );
  table list( t );

  echo("Substitution upward,  Jim only:");
  table substitute vertically selected rows ( u, [Name]==Jim, {Name, Date}, { '"', '...' }, up );
  table list( u );

Output

Original table:
    0 : Name | Date       | Tennis Scores
    1 : Jim  | 2020-06-20 | 6:5 6:2 6:3  
    2 : Jim  | 2020-06-20 | 7:6 6:4 5:6  
    3 : Jim  | 2020-06-21 | 6:2 5:6 4:6  
    4 : Jane | 2020-06-21 | 5:4 6:5 7:6  
    5 : Jane | 2020-06-21 | 3:6 7:6 6:5  

Substitution downward:
    0 : Name | Date       | Tennis Scores
    1 : Jim  | 2020-06-20 | 6:5 6:2 6:3  
    2 : "    | ...        | 7:6 6:4 5:6  
    3 : "    | 2020-06-21 | 6:2 5:6 4:6  
    4 : Jane | ...        | 5:4 6:5 7:6  
    5 : "    | ...        | 3:6 7:6 6:5  

Substitution upward,  Jim only:
    0 : Name | Date       | Tennis Scores
    1 : "    | ...        | 6:5 6:2 6:3  
    2 : "    | 2020-06-20 | 7:6 6:4 5:6  
    3 : Jim  | 2020-06-21 | 6:2 5:6 4:6  
    4 : Jane | 2020-06-21 | 5:4 6:5 7:6  
    5 : Jane | 2020-06-21 | 3:6 7:6 6:5  

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

See also

table fill vertically
table substitute horizontally