table process, table process rows, table process all rows, table process selected rows, table process all selected rows, table process rows up, table process all rows up, table process selected rows up, table process all selected rows up, table process rows start, table process all rows start, table process rows stop, table process all rows stop, table process rows up start, table process all rows up start, table process rows up stop, table process all rows up stop
The function family beginning with table process... is one of the most powerful functions in B4P which allows you to avoid specifying loops and
multiple variables when processing a selection of or all rows in a table. The processing statements and optionally the conditions to check whether to
process the rows are passed as function parameters and applied repeatedly.
Following selection criteria may be applied to decide whether to process each row:
Additional features are provided:
The expressions and/or the statements for processing the data in every row are provided as function parameters and will be executed for every single row selected. Combined with already available table context for partial table specifications, you can do powerful algorithms with minimum amount of simple code text. See code examples further below.
Function Name | Direction | Include row 0 | Remarks |
---|---|---|---|
table process | Top down | No | All rows will be processed. Only the statement and no selection expressions are provided. |
table process rows | Top down | No | See above. |
table process rows up | Bottom up | No | See above. |
table process all rows | Top down | Yes | See above. |
table process all rows up | Bottom up | Yes | See above. |
table process selected rows | Top down | No | The function requires an expression to select the rows, followed by the statements to be executed if true, and optionally followed by statemetns to be executed if false. |
table process selected rows up | Bottom up | No | See above. |
table process all selected rows | Top down | Yes | See above. |
table process all selected rows up | Bottom up | Yes | See above. |
table process rows start | Top down | No | See above and 1. |
table process rows up start | Bottom up | No | See above and 1. |
table process all rows start | Top down | Yes | See above and 1. |
table process all rows up start | Bottom up | Yes | See above and 1. |
table process rows stop | Top down | No | See above and 2. |
table process rows up stop | Bottom up | No | See above and 2. |
table process all rows stop | Top down | Yes | See above and 2. |
table process all rows up stop | Bottom up | Yes | See above and 2. |
1 The start functionality: At the first time the selection criteria affects the the row (true), then all remaining rows to be checked
will also apply. For this reason, the expression will no longer be calculated till the table has been completed.
2 The stop functionality: If the selection criteria does not affect the row (false), then the row will be processed. Once the selection criteria
applies, then the current and all remaining ones to do row will no longer be porcessed. For this reason, the expression will no longer be calculated till the table has been completed.
An additional parameter containing statements (referred as 'Statements (otherwise)') can be specified for all functions except first five function names listed in the
table above. These optional statements will be executed if the specified rows are not selected. This even applies to the function names containing start
and stop.
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
2-4
No. | Type | Description |
---|---|---|
1. input |
string | Name of existing table |
Opt. 2. code |
expression :string |
Expression to select rows Applicable to all functions except table process and table process rows: |
2. / 3. code |
statements :string |
Statements (applicable where rows are selected) Applicable to the functions table process and table process rows: Statements are processed on every row |
4. code |
statements :string |
Statements (otherwise) Applicable to the functions table process and table process rows: Not appicable. Providing a 4th parameter reuslts in an error. |
Type | Description |
---|---|
numeral | Number of rows processed The number of times the statements in the 2nd resp. 3rd paramter (but not 4th paramter) are processed. |
table initialize ( table, {{ Name, Out 1, Out 2, Out 3, Out 4, Out 5, Out 6, Out 7, Out 8 },
Abel, Brigitte, Charles, Daniela, Emily, Fred, Gregor, Hella, Ingo, Jan, Klaus, Linda } );
table copy table ( table, t );
i[] = 1;
table process rows ( t, [Out 1] = i[]++ );
table process all rows ( t, [Out 2] = i[]++ ); // Note: Header 'Out 2' will be verwritten
table process rows up ( t, [Out 3] = i[]++ );
table process all rows up ( t, [Out 4] = i[]++ ); // Note: Header 'Out 4' will be verwritten
i[] = 1;
table process selected rows ( t, {2..5,9,-1}, [Out 5] = i[]++, [Out 5] = No ); // Rows 2-5,9,last row
table process all selected rows ( t, 0, [Out 6] = i[]++ ); // Just row 0
table process selected rows up ( t, ([Name]<>'*a*'), [Out 7] = i[]++, [Out 7] = No );
table process all selected rows up ( t, ([Name]='*m*',Linda), [Out 8] = i[]++ );
// Note the parentheses around the expressions: = and <> may expect multiple operands separated by comma like
// the last example above: Containing 'm' or eqal to 'Linda'.
table list (t);
echo( new line, "Demonstrate the 'start' and 'stop' features:");
table copy table ( table, t );
table process rows start ( t, ([Name]='*n*'), [Out 1] = i[]++, [Out 1] = No );
table process rows stop ( t, ([Name]='*n*'), [Out 2] = i[]++, [Out 2] = No );
table process all rows start ( t, ([Name]='*m*'), [Out 3] = i[]++ );
table process all rows stop ( t, ([Name]='*a'), [Out 4] = i[]++ );
i[] = 1;
table process rows up start ( t, ([Name]='*y'), [Out 5] = i[]++, [Out 5] = No );
table process rows up stop ( t, ([Name]='*y'), [Out 6] = i[]++, [Out 6] = No );
table process all rows up start ( t, ([Name]='*y'), [Out 7] = i[]++ );
table process all rows up stop ( t, ([Name]='*y'), [Out 8] = i[]++ );
table list (t);
0 : Name | Out 1 | 13 | Out 3 | 50 | Out 5 | 7 | Out 7 | 16
1 : Abel | 1 | 14 | 37 | 49 | No | | 13 |
2 : Brigitte | 2 | 15 | 36 | 48 | 1 | | 12 |
3 : Charles | 3 | 16 | 35 | 47 | 2 | | No |
4 : Daniela | 4 | 17 | 34 | 46 | 3 | | No |
5 : Emily | 5 | 18 | 33 | 45 | 4 | | 11 | 15
6 : Fred | 6 | 19 | 32 | 44 | No | | 10 |
7 : Gregor | 7 | 20 | 31 | 43 | No | | 9 |
8 : Hella | 8 | 21 | 30 | 42 | No | | No |
9 : Ingo | 9 | 22 | 29 | 41 | 5 | | 8 |
10 : Jan | 10 | 23 | 28 | 40 | No | | No |
11 : Klaus | 11 | 24 | 27 | 39 | No | | No |
12 : Linda | 12 | 25 | 26 | 38 | 6 | | No | 14
Demonstrate the 'start' and 'stop' features:
0 : Name | Out 1 | Out 2 | 29 | 42 | Out 5 | Out 6 | 18 | Out 8
1 : Abel | No | 26 | 30 | 43 | 5 | No | 17 |
2 : Brigitte | No | 27 | 31 | 44 | 4 | No | 16 |
3 : Charles | No | 28 | 32 | 45 | 3 | No | 15 |
4 : Daniela | 17 | No | 33 | | 2 | No | 14 |
5 : Emily | 18 | No | 34 | | 1 | No | 13 |
6 : Fred | 19 | No | 35 | | No | 12 | | 25
7 : Gregor | 20 | No | 36 | | No | 11 | | 24
8 : Hella | 21 | No | 37 | | No | 10 | | 23
9 : Ingo | 22 | No | 38 | | No | 9 | | 22
10 : Jan | 23 | No | 39 | | No | 8 | | 21
11 : Klaus | 24 | No | 40 | | No | 7 | | 20
12 : Linda | 25 | No | 41 | | No | 6 | | 19
table process selected rows fast
table process cells
table process cells selected rows
table process columns
table manipulate