You are here: Foswiki>Tasks Web>Item13892 (18 Feb 2017, GeorgeClark)Edit Attach

Item13892: CALC doesn't work in %SEARCH despite of what documention says.

Priority: Normal
Current State: Closed
Released In: 2.1.3
Target Release: patch
Applies To: Extension
Component: SpreadSheetPlugin
Branches: Release02x01 master
Reported By: VadimBelman
Waiting For:
Last Change By: GeorgeClark
Despite of what is stated in SpreadSheetPlugin documentation, %CALC{}% used in a format string doesn't work and makes it through into the final topic as is. Instead %CALCULATE{}% works as expected. I'm not sure if it's a SEARCH engine bug or a mistake in the documentation. But the latter looks more likely to me.

-- VadimBelman - 10 Dec 2015

I created a topic to demo the issue:

-- VadimBelman - 10 Dec 2015

After more deep testing it looks more like a bug. It seems that if same SEARCH statement contains both quoted version ($percntCALC{}$percnt) in a format string and unquoted (%CALC{}%) anywhere in the statement then the quoted version isn't expanded at all. But if the quoted version is the only one in the statement then it works as expected.

The example topic above now has both kinds of SEARCH to demonstrate this behavior.

-- VadimBelman - 10 Dec 2015

I've done some debugging of the commonTagsHandler. it is called only once with the $include flag unset. Dumping the $_[0] input to the handler:

  • With 2 %CALC macros, the commonTagsHandler is called with the %SEARCH macro unexpanded. So the unescaped CALC is processed. It is never called a 2nd time with the expanded search results.

  • With only one CALC macro $percnt delayed in the format statement, commonTagsHandler is entered after the SEARCH has expanded and it processes the %CALC macros, one per search hit.

So that's what it's doing, but I have no idea why. I don't believe it should behave this way.

-- GeorgeClark - 10 Dec 2015

I think that the better solution to this is to document that CALCULATE is the way to go.

-- GeorgeClark - 20 Jan 2017

ItemTemplate edit

Summary CALC doesn't work in %SEARCH despite of what documention says.
ReportedBy VadimBelman
Codebase 2.1.3 beta1, 2.1.2, 2.1.1, 2.1.0
SVN Range
AppliesTo Extension
Component SpreadSheetPlugin
Priority Normal
CurrentState Closed
Checkins distro:89425d935731 distro:addab096c662
TargetRelease patch
ReleasedIn 2.1.3
CheckinsOnBranches Release02x01 master
masterCheckins distro:89425d935731 distro:addab096c662
Release02x01Checkins distro:89425d935731
Topic revision: r5 - 18 Feb 2017, GeorgeClark - This page was cached on 29 Mar 2017 - 00:21.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License