You are here: Foswiki>Tasks Web>Item13892 (31 Jan 2018, 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 Item14380 Item14537
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
Topic revision: r7 - 31 Jan 2018, GeorgeClark - This page was cached on 14 Jan 2020 - 18:38.

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