SID-01181: Help with doing INCLUDE inside CALC inside a SEARCH
| Status: |
Answered |
TWiki version: |
4.1.2 |
Perl version: |
|
| Category: |
CategorySearch |
Server OS: |
Ubuntu |
Last update: |
15 years ago |
I'm doing a search for a list of topics that then needs to conditionally include (or exclude) the topic based on a field. Here is the specific search below. What I have found is that the { } around the INCLUDE break the behavior. If I replace them with ( ), it behaves correctly (but doesn't execute the INCLUDE because the syntax is wrong. I have tried escaping the { } various ways and have not found a solution. Any suggestions?
%SEARCH{"META:FIELD.*?SopType.*?%TYPE%"
topic="SopNo*"
scope="text"
casesensitive="on"
regex="on"
nosearch="on"
nototal="on"
order="formfield(SopNumber)"
format="$percntCALC{$IF($EXACT($formfield(SopRetired), %FILTER_RETIRED%), <nop>, $percntINCLUDE{$topic}$percnt )}$percnt"
}%
--
RickMach - 2011-05-19
Discussion and Answer
Try to delay the
%INCLUDE with
$NOP(%)INCLUDE so that it runs after the CALC. Untested:
format="$percntCALC{$IF($EXACT($formfield(SopRetired), %FILTER_RETIRED%), <nop>, $NOP(%)INCLUDE{$topic}$NOP(%) )}$percnt"
--
PeterThoeny - 2011-05-20
That fixed the issue. Thank you!!!
--
RickMach - 2011-05-20
If you don't mind, I would appreciate any thoughts on how the
$NOP(%) is different than the
$percnt. The first evaluation of the
$percent should results in a
%. Doesn't the
$NOP(%) also result in a
% after the first evaluation? Or does that delay it until a second evaluation?
--
RickMach - 2011-05-20
$percent gets resolved by SEARCH, e.g. CALC will see
%INCLUDE too early.
$NOP(%) makes sure that the INCLUDE happens after the CALC, because CALC is handling the
$NOP().
--
PeterThoeny - 2011-05-20
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.