Discussion:
[tw5] Finding a colon in a field using contains
(too old to reply)
Hubert
2018-12-06 15:35:44 UTC
Permalink
Hello,

I'm trying to use the new *contains* filter to determine whether a list
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
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/98f2bf2a-7a5b-4d34-b10d-2e404d60586f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Mark S.' via TiddlyWiki
2018-12-06 16:56:18 UTC
Permalink
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
Post by Hubert
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.
\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
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/afe31390-2714-418e-8c03-46cc7c0db31a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hubert
2018-12-06 17:02:29 UTC
Permalink
Mark,

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

Best regards,
Hubert
Post by 'Mark S.' via 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
\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
Post by Hubert
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.
\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
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/53580964-62b8-49f8-a7ef-9247a9c0f427%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...