Finding a colon in a field using contains

38 views
Skip to first unread message

Hubert

unread,
Dec 6, 2018, 10:35:44 AM12/6/18
to tiddl...@googlegroups.com
Hello,

I'm trying to use the new contains filter to determine whether a field note in the tiddler $:/note contains a colon (:) but my code fails and I'm obviously doing something wrong. I'd appreciate if anyone could point me in the right direction.

Here's my code:

\define test1()
<$set name=source value={{$:/note!!note}}>
<$set name=content value=":">
<<test2>>
</
$set>
</$set>
\end

\define test2()
<$list filter="[[$(source)$]contains[$(content)$]]">
YES <<currentTiddler>>
</
$list>
<$list filter="[[$(source)$]!contains[$(content)$]]">
No <<currentTiddler>>
</$list>
\end

<<test1>>

Thank you in advance.

Best regards.
Hubert

Mark S.

unread,
Dec 6, 2018, 11:56:18 AM12/6/18
to TiddlyWiki
I hadn't looked closely at "contains". 

The things to note are that "contains" takes a title list (a list of titles) as input -- NOT a string of text. And, it only matches by complete tokens from a specified list field.
So, this version of your code works IF you have the colon standing on it's own:


\define test1()
<$set name=source value="$:/note">
<$set name=content value=":">
<<test2>>
</$set>
</
$set>
\end

\define test2()
<$list filter="[[$(source)$]contains:note[$(content)$]]">
YES
<<currentTiddler>>
</$list>
<$list filter="[[$(source)$]!contains:note[$(content)$]]">
No <<currentTiddler>>
</
$list>
\end

<<test1>>

This alternative version of your code probably comes closer to what you wanted to do. It uses the search filter operator

\define test1()
<$set name=source value="$:/note">
<$set name=content value=":">
<<test2>>
</$set>
</
$set>
\end

\define test2()
<$list filter="[[$(source)$]search:note[$(content)$]]">
YES
<<currentTiddler>>
</$list>
<$list filter="[[$(source)$]!search:note[$(content)$]]">
No <<currentTiddler>>
</
$list>
\end

<<test1>>


Good luck
-- Mark

Hubert

unread,
Dec 6, 2018, 12:02:29 PM12/6/18
to TiddlyWiki
Mark,

Your other solution works exactly as I needed it. Thank you!

Best regards,
Hubert
Reply all
Reply to author
Forward
0 new messages