This question about Topic Markup Language and applications: Answered

String comparisons in IfStatements

In IfStatements I can't find examples of more advanced string comparisons.

Are there any possibilites to compare if string

I know that I provided examples from Python, but Perl also have more advanced string comparisons possibilites: http://stackoverflow.com/questions/7011524/perl-if-string-contains-text

-- MateuszKDzior - 09 Oct 2015

IF Statements in TML are very limited. You could extend this however by using the %CALCULATE% macro of the SpreadSheetPlugin to do some of the string manipulation.
  • %CALCULATE{$FIND(tion,%TOPIC%)}% evaluates to: 5
  • %CALCULATE{$LEFTSTRING(%TOPIC%,8)}% evaluates to: Question
  • %CALCULATE{$RIGHTSTRING(%TOPIC%,4)}% evaluates to: 1696

So considering the inside-out left-right rendering, you can combine these:
  • %IF{"%CALCULATE{$FIND(tion,%TOPIC%)}%=5" then="'tion' found in position 5"}%
  • 'tion' found in position 5

-- GeorgeClark - 09 Oct 2015
 

QuestionForm edit

Subject Topic Markup Language and applications
Extension
Version Foswiki 2.0.0
Status Answered
Related Topics
Topic revision: r2 - 09 Oct 2015, GeorgeClark
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