Question
I'm having some problems combining SEARCH and CALC functions in a single table. I have reduced my problem to a simplified example shown below.
Columns 3 and 4 use the SEARCH function to find two numbers on the
WebHome topic. Column 5 uses the CALC function to sum the values from columns 3 and 4. For row 1, I specify topic="WebHome" in the search function. For row 2, I nest the CALC function inside the SEARCH function to get the topic name from the table instead of specifying explicitly. Although the correct values are found for columns 3 and 4, the sum in column 5 is no longer correct.
The raw data for the table is below:
| *row* | *TWiki Topic* | *Search number from topic* | *Search another number from topic* | *Sum two numbers* |
| 1 | WebHome | %SEARCH{ "." topic="WebHome" nonoise="on" format="$pattern(.*([0-9]{2}).*)" }% | %SEARCH{ "." topic="WebHome" nonoise="on" format="$pattern(.*?([0-9]{2}).*)" }% | %CALC{$SUM($T(R$ROW():C3),$T(R$ROW():C4))}% |
| 2 | WebHome | %SEARCH{ "." topic="%CALC{"$T(R$ROW():C2)"}%" nonoise="on" format="$pattern(.*([0-9]{2}).*)" }% | %SEARCH{ "." topic="%CALC{"$T(R$ROW():C2)"}%" nonoise="on" format="$pattern(.*?([0-9]{2}).*)" }% | %CALC{$SUM($T(R$ROW():C3),$T(R$ROW():C4))}% |
I have spent several hours trying to sort this out and going through similar support questions, but have so far been unsuccesful. Any help to fix this is greatly appreciated.
Environment
--
ChrisPurves - 23 Nov 2006
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
I do not think this is possible due to the rendering order of TWiki. Cairo evaluated first the internal variables (such as SEARCH), then the plugins (such as CALC). TWiki 4.0 evaluates variables inside out. So, it is not possible to have a CALC evaluated before SEARCH, and then CALC evaluate on the result of SEARCH.
--
PeterThoeny - 26 Nov 2006
Okay, that makes sense. Thanks.
--
ChrisPurves - 28 Nov 2006