We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
Tags:
create new tag
, view all tags

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.

row TWiki Topic Search number from topic Search another number from topic Sum two numbers
1 WebHome 4 9 13
2 WebHome 4 9 0

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

TWiki version: TWikiRelease04x00x05
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin, SpreadSheetPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Search, Plugins

-- ChrisPurves - 23 Nov 2006

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list 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

 
Change status to:
Topic revision: r4 - 28 Nov 2006 - 21:28:21 - ChrisPurves
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback