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