table substitute horizontally ...

Prev Next

Function Names

table substitute horizontally, table substitute horizontally 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

1-6

Parameters

No.TypeDescription
1.
input
string Name of existing table

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

Applicable to table substitute horizontally 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), ....

Opt 2. / 3.
input
table column Starting column to repeat

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.

Default value: 0 (first column)
Opt 3. / 4.
input
table column Ending column to repeat

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.

Default value: (last column)
Opt. 4. / 5.
input
string Substitution string

The substitution string specified here will be used to replace repeated contents. Good examples: '', '...', 'same'.

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

Following values are supported: left and right for repeating contents in left resp. right direction.

Default value: right

Examples

       table initialize( a,
                       { { Last Name,    Jan,    Feb,    Mar,    Apr,    May,    June },
                         { Miller,       5,      6,      15,     15,     15,     25   },
                         { Muller,       '',     6,      6,      6,      14,     14   },
                         { Tanner,       7,      7,      17,     17,     17,     17   },
                         { Gerber,       '',     9,      10,     11,     12,     12   } } );

       echo("Original table:");
       table list(a);
       table copy table ( a, b );

       echo("Substitte from left to right");
       table substitute horizontally ( b, Jan, -1, '...'  );
       table list(b);

       echo("Substitute from right to left ");
       table substitute horizontally ( a, Jan, -1, '...', left  );
       table list(a);

Output

Original table:
    0 : Last Name | Jan | Feb | Mar | Apr | May | June
    1 : Miller    | 5   | 6   | 15  | 15  | 15  | 25  
    2 : Muller    |     | 6   | 6   | 6   | 14  | 14  
    3 : Tanner    | 7   | 7   | 17  | 17  | 17  | 17  
    4 : Gerber    |     | 9   | 10  | 11  | 12  | 12  

Substitte from left to right
    0 : Last Name | Jan | Feb | Mar | Apr | May | June
    1 : Miller    | 5   | 6   | 15  | ... | ... | 25  
    2 : Muller    |     | 6   | ... | ... | 14  | ...
    3 : Tanner    | 7   | ... | 17  | ... | ... | ...
    4 : Gerber    |     | 9   | 10  | 11  | 12  | ...

Substitute from right to left
    0 : Last Name | Jan | Feb | Mar | Apr | May | June
    1 : Miller    | 5   | 6   | ... | ... | 15  | 25  
    2 : Muller    |     | ... | ... | 6   | ... | 14  
    3 : Tanner    | ... | 7   | ... | ... | ... | 17  
    4 : Gerber    |     | 9   | 10  | 11  | ... | 12  

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

See also

table fill horizontally
table substitute vertically