table process selected rows fast
In contrast to table process selected rows(), you can achieve significant performance improvment if the targeted table is sorted and and the Boolean expression tests at least on the sorting value. It becomes useful when calling this function from a loop processing the same or different table, including calling out from code inside table process() / table process selected rows().
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
5
No. | Type | Description |
---|---|---|
1. input |
string | Name of existing table |
2. code |
expression :string |
Expression to select rows Specify the conditions or rules to select the rows. See expressions to select rows. |
3. io |
numeral | Starting row number Specify the starting row number to checking and processing. The range is between 1 and total number of rows minus 1. 0 will be corrected to 1. |
4. input |
string | Processing option Use one of the following values: continue
stop
repeat works similarly as continue, but following differences apply:
repeat remaining works similarly as repeat, but following differences apply:
repeat revolving works similarly as repeat, but following differences apply:
Hint: See also illustration in the next section, Additional info on fast processing of rows. |
5. code |
statements :string |
Statements (applicable where rows are selected) table process: The statements provided will be executed for every row. |
Type | Description |
---|---|
numeral | Number of rows processed |
table initialize ( t, { { Name, Game Score, Done},
{ Andy, 21 }, { Andy, 12 }, { Andy, 20 }, { Max, 50 }, { Max, 31 },
{ Tina, 32 }, { Andy, 44 }, { Andy, 16 }, { Max, 25 }, { Tina, 19 } } );
// table sort rows ( t, Name );
echo("Original table, sorted by name: ");
table list( t );
echo("Example 1: Demonstrate processing option 'continue':");
table copy table ( t, t1 );
row[] = 1; counter[] = 1;
do
{
c[] = table process selected rows fast( t1, [Name]==Andy, row[], continue, [Done] = counter[]++ );
echo("Row number returned: ", row[], ", Items processed: ", c[] );
}
while (c[] > 0);
table list( t1 );
echo("Example 2: Demonstrate processing option 'stop':");
table copy table ( t, t1 );
row[] = 1; counter[] = 1;
do
{
c[] = table process selected rows fast( t1, [Name]==Andy, row[], stop, [Done] = counter[]++ );
echo("Row number returned: ", row[], ", Items processed: ", c[] );
}
while (c[] > 0);
table list( t1 );
echo("Example 3: Demonstrate processing option 'repeat':");
table copy table ( t, t1 );
row[] = 1; counter[] = 1;
c[] = table process selected rows fast( t1, [Name]==Max, row[], repeat, [Done] = counter[]++ ); // Stops
echo("Row number returned: ", row[], ", Items processed: ", c[] );
row[] = 6;
c[] = table process selected rows fast( t1, [Name]==Max, row[], repeat, [Done] = counter[]++ ); // Processing
echo("Row number returned: ", row[], ", Items processed: ", c[] );
row[]++; // Next row
c[] = table process selected rows fast( t1, [Name]==Max, row[], repeat, [Done] = counter[]++ ); // Processing
echo("Row number returned: ", row[], ", Items processed: ", c[] );
table list( t1 );
echo("Example 4: Demonstrate processing option 'repeat remaining':");
table copy table ( t, t1 );
row[] = 3; counter[] = 1;
c[] = table process selected rows fast( t1, [Name]==Andy, row[], repeat remaining, [Done] = counter[]++ ); // Stops
echo("Row number returned: ", row[], ", Items processed: ", c[] );
table list( t1 );
echo("Example 5: Demonstrate processing option 'repeat revolving':");
table copy table ( t, t1 );
row[] = 10; counter[] = 1; // Will find nothing below row 10, so continue from beginning
c[] = table process selected rows fast( t1, [Name]==Andy, row[], repeat revolving, [Done] = counter[]++ ); // Stops
echo("Row number returned: ", row[], ", Items processed: ", c[] );
table list( t1 );
Original table, sorted by name:
0 : Name | Game Score | Done
1 : Andy | 21 |
2 : Andy | 12 |
3 : Andy | 20 |
4 : Max | 50 |
5 : Max | 31 |
6 : Tina | 32 |
7 : Andy | 44 |
8 : Andy | 16 |
9 : Max | 25 |
10 : Tina | 19 |
Example 1: Demonstrate processing option 'continue':
Row number returned: 4, Items processed: 3
Row number returned: 9, Items processed: 2
Row number returned: 11, Items processed: 0
0 : Name | Game Score | Done
1 : Andy | 21 | 1
2 : Andy | 12 | 2
3 : Andy | 20 | 3
4 : Max | 50 |
5 : Max | 31 |
6 : Tina | 32 |
7 : Andy | 44 | 4
8 : Andy | 16 | 5
9 : Max | 25 |
10 : Tina | 19 |
Example 2: Demonstrate processing option 'stop':
Row number returned: 4, Items processed: 3
Row number returned: 4, Items processed: 0
0 : Name | Game Score | Done
1 : Andy | 21 | 1
2 : Andy | 12 | 2
3 : Andy | 20 | 3
4 : Max | 50 |
5 : Max | 31 |
6 : Tina | 32 |
7 : Andy | 44 |
8 : Andy | 16 |
9 : Max | 25 |
10 : Tina | 19 |
Example 3: Demonstrate processing option 'repeat':
Row number returned: 4, Items processed: 2
Row number returned: 9, Items processed: 1
Row number returned: 10, Items processed: 0
0 : Name | Game Score | Done
1 : Andy | 21 |
2 : Andy | 12 |
3 : Andy | 20 |
4 : Max | 50 | 1
5 : Max | 31 | 2
6 : Tina | 32 |
7 : Andy | 44 |
8 : Andy | 16 |
9 : Max | 25 | 3
10 : Tina | 19 |
Example 4: Demonstrate processing option 'repeat remaining':
Row number returned: 3, Items processed: 3
0 : Name | Game Score | Done
1 : Andy | 21 |
2 : Andy | 12 |
3 : Andy | 20 | 1
4 : Max | 50 |
5 : Max | 31 |
6 : Tina | 32 |
7 : Andy | 44 | 2
8 : Andy | 16 | 3
9 : Max | 25 |
10 : Tina | 19 |
Example 5: Demonstrate processing option 'repeat revolving':
Row number returned: 1, Items processed: 3
0 : Name | Game Score | Done
1 : Andy | 21 | 1
2 : Andy | 12 | 2
3 : Andy | 20 | 3
4 : Max | 50 |
5 : Max | 31 |
6 : Tina | 32 |
7 : Andy | 44 |
8 : Andy | 16 |
9 : Max | 25 |
10 : Tina | 19 |