Setting the emptyValue in Set Widget

37 views
Skip to first unread message

Mohammad

unread,
Jun 29, 2018, 1:21:35 AM6/29/18
to tiddl...@googlegroups.com
I have a small macro to sweep a list of tiddlers from first to last

Here parent is a tag name some tiddlers has been tagged with. The following code works
Here I have used two set widgets, one to set the emptyValue

\define nextItem(parent)
 <$set 
   filter='[tag[$parent$]first[]]'
   name=emptyTid
  >
 <$set
 filter='[tag[$parent$]after{!!temp}]'
 name=NewIndex
 emptyValue=<<emptyTid>>
 >
  <$action-setfield
   $tiddler={{!!title}}
   temp=<<NewIndex>>
   />
</$set>
</$set>
\end


<$button actions=<<nextItem "myTag">> >Next</$button>



But if I directly set the emptyValue and I have used only one set widget. But it does not work!!


\define nextItem(parent)
 <$set
 filter='[tag[$parent$]after{!!temp}]'
 name=NewIndex
 emptyValue='[tag[$parent$]first[]]'
 >
  <$action-setfield
   $tiddler={{!!title}}
   temp=<<NewIndex>>
   />
</$set>
\end


<$button actions=<<nextItem "myTag">> >Next</$button>



What is the problem? Why I have to use two set widegets?


/Mohammad

Jeremy Ruston

unread,
Jun 29, 2018, 3:16:26 AM6/29/18
to tiddl...@googlegroups.com
Hi Mohammad


But if I directly set the emptyValue and I have used only one set widget. But it does not work!!

\define nextItem(parent)
 <$set
 filter='[tag[$parent$]after{!!temp}]'
 name=NewIndex
 emptyValue='[tag[$parent$]first[]]'
 >
  <$action-setfield
   $tiddler={{!!title}}
   temp=<<NewIndex>>
   />
</$set>
\end


<$button actions=<<nextItem "myTag">> >Next</$button>

What is the problem? Why I have to use two set widegets?

The problem here is that the emptyValue attribute of the set widget is interpreted as a string, not as a filter. So, rather than getting the results of the filter you'll get the text of the filter itself.

Things should work if you add the triple braces filtered transcluded attribute syntax:

\define nextItem(parent)
 <$set
 filter='[tag[$parent$]after{!!temp}]'
 name=NewIndex
 emptyValue={{{ [tag[$parent$]first[]] }}}
 >
  <$action-setfield
   $tiddler={{!!title}}
   temp=<<NewIndex>>
   />
</$set>
\end


<$button actions=<<nextItem "myTag">> >Next</$button>


The triple braces syntax can be used with any attribute: the attribute is assigned the first result from evaluating the filter.

Best wishes

Jeremy.



/Mohammad

--
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 tiddl...@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/b4d6080c-3bcb-4d9a-a34b-421def0a6d82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mohammad

unread,
Jun 29, 2018, 3:33:44 AM6/29/18
to TiddlyWiki
Wonderful!

Jeremy is there any document in tiddlywiki.com or other placed to explain these rules?
Examples like:
{!!title}
{!!title}
<myVar>
<<myVar>>



Best
Mohammad

Jeremy Ruston

unread,
Jun 29, 2018, 3:50:56 AM6/29/18
to tiddl...@googlegroups.com
Hi Mohammad


On 29 Jun 2018, at 08:33, Mohammad <mohammad...@gmail.com> wrote:


Jeremy is there any document in tiddlywiki.com or other placed to explain these rules?

There is an attempt to document this stuff at https://tiddlywiki.com/#Transclusion%20and%20Substitution

Best wishes

Jeremy.

Mohammad

unread,
Jun 29, 2018, 4:10:59 AM6/29/18
to TiddlyWiki
Thank you Jeremy!

Best wishes
Mohammad

Mohammad

unread,
Jun 29, 2018, 5:28:40 AM6/29/18
to TiddlyWiki
Jeremy,
 One more point:
When the result of filter in the set widget is tiddlers with space in the name like My Tiddler, the list widget return [[My Tiddler]] this cause the code breaks. Note to [[]] in the result.
Based on your explanation I used the following syntax


\define nextItem(parent)
<$set
 filter={{{ [tag[$parent$]after{!!temp}]}}}
name=NewIndex
emptyValue='[tag[$parent$]first[]]'
>
 <$action-setfield
  $tiddler={{!!title}}
  temp=<<NewIndex>>
  />
</$set>
\end

No it works! I mean the new code works even when the filter return [[My Tiddler]]?

Is it the correct way?


/Mohammad
Reply all
Reply to author
Forward
0 new messages