Suggestion for checking if a Tiddler is empty?

83 views
Skip to first unread message

David Szego

unread,
Jan 1, 2019, 7:46:11 PM1/1/19
to TiddlyWikiDev
Hi all, happy new year. Hope it's a great one for all of you and for the project!

Can anyone suggest a filter or list that will give me a true/false if a Tiddler is empty (has no text)? Couldn't find an answer here...

Thanks,
David.

Mal Gamble

unread,
Jan 1, 2019, 9:45:08 PM1/1/19
to TiddlyWikiDev
[has[text]]

Regards,

Mal

Mohammad Rahmani

unread,
Jan 1, 2019, 11:03:49 PM1/1/19
to TiddlyWikiDev
This macro can return the name of tiddler and a true/false if it has / has not text

\define hasText(tid)
<$set name="Tiddler" value=<<__tid__>> >
<$reveal type="match" default=<<Tiddler>> text={{{ [<Tiddler>has[text]] }}}>
<<Tiddler>>: True
</$reveal>
<$reveal type="nomatch" default=<<Tiddler>> text={{{ [<Tiddler>has[text]] }}}>
<<Tiddler>>: False
</$reveal>
</$set>
\end


  • Test
In https://tiddlywiki.com/ create two tiddlers one Test01 and the other Test02, put a text in the first tiddler and leave empty the second, then try as below

<<hasText Test01>>
<
<hasText Test02>>



The results will be

Test01: False

Test02: True


If you like to use it inside a list widget, tag above two tiddlers with something e.g test

<$list filter="[tag[test]]">
<$macrocall $name="hasText" tid=<<currentTiddler>> /><br>
</$list>


You will have then:

Test01: False
Test02: True


Good luck
Mohammad

Elijah

unread,
Mar 12, 2019, 6:34:47 PM3/12/19
to tiddly...@googlegroups.com
What about checking for a specific string - how would I go about doing that?

PMario

unread,
Mar 12, 2019, 9:10:18 PM3/12/19
to TiddlyWikiDev
On Tuesday, March 12, 2019 at 11:34:47 PM UTC+1, Elijah wrote:
What about checking for a specific string - how would I go about doing that?

IMO reveal-widget may be of use? https://tiddlywiki.com/#RevealWidget

-m

Elijah

unread,
Mar 12, 2019, 11:42:35 PM3/12/19
to TiddlyWikiDev
Thanks. That link had the rest of the information I needed to figure it out. Setting the state equal to the tiddlerTitle!!text and then the text to the string, in quotations, worked. Was also able to remove the "default=<<Tiddler>>" entirely.
Reply all
Reply to author
Forward
0 new messages