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     0
2 WebHome     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 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

Change status to:
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2006-11-28 - ChrisPurves
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.