table fill horizontally ...

Prev Next

Function Names

table fill horizontally, table fill horizontally selected rows

Description

In various tables, contents are mentioned in only one column and the columns to the right (or left) are kept blank even though the same contents are assumed. This function will repeat the contents accordingly.

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 fill 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 Strings representing repetition

Provide one string with matching pattern. This one will apply to all rows and columns. Soft quoted strings allow use of wildcard symbols in order to compare for different strings, e.g. 'see above*,' covers begins with 'see above' and equals to blanks (note the comma at the end).
Good examples: '"', '', "(see above)", "ditto", 'see above,look above',"*...*",'see*'
Note: If the 1st (or last) item is already deemed as blank (e.g. 'same'), then it will not be overwritten because no non-blank value is available yet.

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,      '',     15,     '',     '',     25   },
                         { Muller,       '',     '',      6,     '',     14,     ''   },
                         { Tanner,       7,      same,    17,    same,   same,   ''   },
                         { Gerber,       '',     same,    0,     10,     11,     12   } } );

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

       echo("Fill from left to right");
       table fill horizontally ( b, Jan, -1, 'same,'  );
       table list(b);

       echo("Fill from right to left ");
       table fill horizontally ( a, Jan, -1, 'same,', left  );
       table list(a);

Output

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

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

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

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

See also

table fill vertically
table substitute horizontally