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

Is it possible to use SpreadSheetPlugin calculations in a table that is created dynamically from a formatted search?.

What I want to achieve is the following:

I have a form where the user can rate for a topic based on some criteria (e.g. Producability, Cost, Reliability etc.).

A search should then build a table wich automatically builds an aggregate score for all topics by multiplying individual scores:

So I'd like something like this:

|*Topic*|*P*|*C*|*R*|*Score*|
%SEARCH{ "Scoringdata" scope="text" regex="on" nosearch="on" nototal="on" format="| $formfield(.) | ...| $formfield(.)|%CALC{"$SUM( $LEFT())"}%|" }%

To produce something like this:

Topic P C R Score
DoorKnobSolutionWithClamps 1 5 1 7
DoorKnobSolutionWithouClamps 3 5 3 11
. . . . .
. . . . .
WhatEver 2 4 3 9

I've not been able to escape the %CALC{..}% stuff in such a way that it calculates scores in the automaticallly generated rows.

Should this be possible or am I asking too much here?

  • TWiki version:01 Dec 2001
  • Web server:apache
  • Server OS:Linux
  • Web browser:mozilla 0.9.9, IE 5.5
  • Client OS:Linux, IRIX, Win NT

-- GerritJanBaarda - 02 May 2002

Answer

The %SEARCH% pattern is non-greedy for the closing }%, e.g. s/%SEARCH{(.*?)}%/&handleSearchWeb($1)/geo;. This is because more then one search could be on one line. That also means that nesting variables with parameters is not supported. In your case, %SEARCH% will incorrectly match the closing }% of the %CALC%.

There is a workaround. You need to build a %CALC% where the closing }% gets built by the search itself. For example, insert something in between } and % that disappers after a search, e.g. a never matching pattern. Using your example:

%SEARCH{ "Scoringdata" scope="text" regex="on" nosearch="on" nototal="on" format="| $formfield(foo) | ...| $formfield(bar)|%CALC{\"$SUM( $LEFT())\"}$pattern(.*?(never-matching-pattern).*)%|" }%

-- PeterThoeny - 05 May 2002

Topic revision: r2 - 05 May 2002 - 06:10:49 - PeterThoeny
 
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