Tags:
create new tag
view all tags

SID-01181: Help with doing INCLUDE inside CALC inside a SEARCH

Status: Answered 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

      Change status to:
ALERT! 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.
SupportForm
Status Answered
Title Help with doing INCLUDE inside CALC inside a SEARCH
SupportCategory CategorySearch
TWiki version 4.1.2
Server OS Ubuntu
Web server Apache 1.2
Perl version

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2011-05-20 - 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-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.