\define mm(newField)
<$list filter="[<__newField__>] -[[]]">
Do my job!
</$list>
\end
<<mm test>>
\define test(tiddler)
<$set name="result" filter="[[$tiddler$]] -[[]]" value="Why is this variable set when the filter ''is not missing'' and ''it's empty''?">
The description of the ''value'' attribute of the `$set` widget says: The value to assign to the variable if the filter is missing or ''//not empty//''
tiddler=$tiddler$
result=<<result>>
<$list filter="[[$tiddler$]] -[[]]" emptyMessage="See, the filter shows it's Empty">
</$list>
</$set>
\end
<<test>>
filter="[enlist[$tiddler$]]"
filter=" $tiddler$"
<$view>
widget is displayed if the field or property is missing or empty.--
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/1867389e-59de-4b9e-b8e6-6ecd9212d92e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.
Perhaps it would be clearer expressed as a series of examples...
1. If the "tiddler" attribute is present, get the text of the tiddler, or the value of the "emptyValue" attribute if the text field is blank or missing
<$set name="myvar" tiddler="SomeTiddler" emptyValue="sometext">
1a. If the "subtiddler" attribute is present, get the text of the subtiddler from the specified tiddler, or the value of the "emptyValue" attribute if the subtiddler text is blank or missing
<$set name="myvar" tiddler="SomeTiddler" subtiddler="SomeSubTiddler" emptyValue="sometext">
1b. If the "field" attribute is present, get the value of that field, or the value of the "emptyValue" attribute if the field is blank or missing
<$set name="myvar" tiddler="SomeTiddler" field="somefield" emptyValue="sometext">
1c. If the "index" attribute is present, get the value of the specified index, or the value of the "emptyValue" attribute if the index is blank or missing
<$set name="myvar" tiddler="SomeTiddler" index="somefield" emptyValue="sometext">
2. If the "filter" attribute is present and not blank, return the entire filter results using double square brackets quoting around any results that include spaces
<$set name="myvar" filter="[somefilter[]]">
2a. If both the "filter" attribute and the "value" attribute are present and the filter results are not empty, return the value of the "value" attribute, otherwise return blank
<$set name="myvar" filter="[somefilter[]]" value="somevalue">
2b. If both the "filter" attribute and the "emptyValue" attribute are present, return the entire filter results using double square brackets quoting around any results that include spaces, or the value of the "emptyValue" attribute if the result is empty
<$set name="myvar" filter="[somefilter[]]" emptyValue="sometext">
2c. If the "filter" attribute, the "value" attribute, and the "emptyValue" attribute are present, return the value of the "value" attribute, or the value of the "emptyValue" attribute if the result is empty
<$set name="myvar" filter="[somefilter[]]" value="somevalue" emptyValue="sometext">
2d. If both the "filter" attribute and the "select" attribute are present and the "select" attribute is a valid number "N", return the "Nth" result from the filter
<$set name="myvar" filter="[somefilter[]]" select="3">
3. If neither the "tiddler" or "filter" attributes are provided, return the value of the "value" attribute, or the value of the "emptyValue" attribute if the "value" attribute is blank or missing
<$set name="myvar" value="somevalue" emptyValue="sometext">
<$set name="myvar" tiddler="SomeTiddler" emptyValue="sometext">
<$set name="myvar" tiddler="SomeTiddler" subtiddler="SomeSubTiddler" emptyValue="sometext">
<$set name="myvar" tiddler="SomeTiddler" field="somefield" emptyValue="sometext">
<$set name="myvar" tiddler="SomeTiddler" index="somefield" emptyValue="sometext">
<$set name="myvar" tiddler="" filter="[somefilter[]]" emptyValue="sometext">
<$set name="myvar" tiddler="" filter="[somefilter[]]">
<$set name="myvar" tiddler="" value="" emptyValue="sometext">
<$set name="myvar" tiddler="" value="somevalue">
<$set name="myvar" filter="[somefilter[]]">
<$set name="myvar" filter="[somefilter[]]" value="somevalue">
<$set name="myvar" filter="[somefilter[]]" emptyValue="sometext">
<$set name="myvar" filter="[somefilter[]]" value="somevalue" emptyValue="sometext">
<$set name="myvar" filter="[somefilter[]]" select="3">
<$set name="myvar" filter="[somefilter[]]" select="">
<$set name="myvar" filter="[somefilter[]]" select="1000" emptyValue="this won't be returned">
<$set name="myvar" filter="[someBadfilter[]]" select="1000" emptyValue="this will be returned">
<$set name="myvar" value="somevalue" emptyValue="sometext">
If the "value" attribute is present and the filter results are empty, return the value of the "emptyValue" attribute, if present, otherwise return a blank result
<$set name="temp" tiddler="date-settings-tiddler" field="template-day" emptyValue=<<template-day-default>>>
<$set name="temp-template" filter="[enlist[$template$]]" value="$template$" emptyValue=<<temp>>>
<$set name="template" filter="[enlist[$template-day$]]" value="$template-day$" emptyValue=<<temp-template>>>
Code using <<template>>
</$set>
</$set>
</$set>
\define mymacro(tiddlername)
<$set name=selected-tiddler value="$tiddlername$" emptyValue=<<currentTiddler>> >
Action: <<selected-tiddler>>
</$set>
\end
<<mymacro>>
<<mymacro "another tiddler">>