Implemented: Expand Variables on Formatted Search with expandvariables Flag
In some cases it is useful to apply a
FormattedSearch on text where the
%VARS{}% variables are expanded. For example, you search topics that have a
%CALC{}% in a table cell, and you want to show the result of the formula applied to the search hit topic, not to the topic where SEARCH is.
To do that,
%SEARCH{}% has now a new expandvariables switch:
expandvariables="on" |
Expand variables before applying a FormattedSearch on a search hit. Useful to show the expanded text, e.g. to show the result of a %CALC{}% instead of the formula |
Raw text |
Example
This is a silly example that searches this topic and pulls the total from this table:
| Region: |
Sales: |
| Northeast |
320 |
| Northwest |
580 |
| South |
240 |
| Europe |
610 |
| Asia |
220 |
| Total: |
1970 |
The cell next to Total has this formula:
%CALC{"$SUM( $ABOVE() )"}%
Normal SEARCH where
"$SUM( $ABOVE() )" is calculated
after the SEARCH:
%SEARCH{ "Total" topic="ExpandVariablesOnFormattedSearch" format=" * Total: $pattern(.*?\| Total\:[^\|]+\|([^\|]+).*)" nosearch="on" nototal="on" }%
SEARCH with
expandvariables="on" where the formula is evaluated
before the formatted search:
%SEARCH{ "Total" topic="ExpandVariablesOnFormattedSearch" format=" * Total: $pattern(.*?\| Total\:[^\|]+\|([^\|]+).*)" nosearch="on" nototal="on" expandvariables="on" }%
Contributors:
--
PeterThoeny - 27 Feb 2004
Discussions
Change is in
TWikiAlphaRelease and at TWiki.org.
--
PeterThoeny - 27 Feb 2004
Small enhancement affecting only a multiple=on search:
- Old spec: The variables got expanded inside the multiple=on loop
- New spec: The variables get expanded on the whole topic before the multiple=on loop
- Purpose: A multiple=on search catches now also content produced by another SEARCH located in the searched topic
Enhancement is in
TWikiAlphaRelease.
--
PeterThoeny - 12 Mar 2004