create new tag
, view all tags

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


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" }%

  • Total: 1970

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" }%

  • Total: 1970

-- PeterThoeny - 27 Feb 2004


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

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2004-03-12 - PeterThoeny
  • 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-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.