Added to TW-Scripts

On Sunday, March 31, 2019 at 7:16:22 PM UTC+4:30, Jeremy Ruston wrote:
>
> Hi SS
>
> The logic used by the set widget to determine the result assigned to the 
> variable is as follows:
>
> 1. If the "tiddler" attribute is present and not blank, then:
> 1a. If the "subtiddler" attribute is also present and not blank, then get 
> the subtiddler from the specified tiddler, otherwise just get the tiddler 
> itself
> 1b. If the "field" attribute is present then return return the value of 
> that field, or the value of the "emptyValue" attribute if the field is 
> blank or missing
> 1c. Otherwise, if the "index" attribute is present, return the value of 
> the specified index, or the value of the "emptyValue" attribute if the 
> index is blank or missing
> 1d. Otherwise, return the text field of the tiddler, or the value of the 
> "emptyValue" attribute if the text field is blank or missing
>
> 2. If the "filter" attribute is present and not blank, then evaluate the 
> results of the filter, and:
> 2a. If the "value" attribute is present and the filter results are not 
> empty, return the value of the "value" attribute (even if the "value" 
> attribute is blank)
> 2b. 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
> 2c. If the "value" attribute is not present, then if the "select" 
> attribute is a valid number it is used to retrieve a specified result from 
> the filter
> 2d. If the "value" attribute is not present, and the "select" attribute is 
> not a valid number, and the filter results are not empty, then the entire 
> filter results are returned (using double square brackets quoting around 
> any results that include spaces)
> 2e. If the "value" attribute is not present, the "select" attribute is not 
> a valid number, and the filter results are empty, then the value of the 
> "emptyValue" attribute is returned (or blank if it is not present)
>
> 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
>
> Perhaps it would be clearer expressed as a series of examples...
>
> Best wishes
>
> Jeremy
>
> --
> Jeremy Ruston
> jer...@jermolene.com <javascript:>
> https://jermolene.com
>
> On 30 Mar 2019, at 16:17, S. S. <sachde...@gmail.com <javascript:>> wrote:
>
> Within a macro, I am trying to determine if a parameter is empty, and then 
> set a variable based on knowing that it is empty.
>
> I came across the Google Group post from a last month: Check the Blank 
> Macro parameter 
> <https://groups.google.com/forum/?hl=en#!topic/tiddlywiki/82N15sAnoPs/discussion>
> \define mm(newField)
> <$list filter="[<__newField__>] -[[]]">
>
> Do my job!
> </$list>
> \end
>
>
> <<mm test>>
>
> So I tried using something based on that. Pasting the below into a new 
> tiddler on tiddlywiki.com shows the issue:
>
> \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>>
>
>
> I don't understand where I've gone wrong. I'd appreciate some advice.
> Thanks.
>
>
> -- 
> 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 tiddl...@googlegroups.com <javascript:>.
> To post to this group, send email to tiddl...@googlegroups.com 
> <javascript:>.
> 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
>  
> <https://groups.google.com/d/msgid/tiddlywiki/1867389e-59de-4b9e-b8e6-6ecd9212d92e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@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/85221747-8ab2-416f-a4ba-4dbf0da42562%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to