Eric,

Thanks for your reply.

One question. You reference the macro parameter using multiple braces but the 
documentation says to use <<__...__>>. Is this documented somewhere?

BobJ

---------------
Dr Bob Jansen
The Cultural Conversations project 
Turtle Lane Studios Pty Ltd trading as the Australian Centre for Oral History
122 Cameron St, Rockdale NSW 2216, Australia 
Ph (Korea): +82 10-4494-0328 
Ph (Australia) +61 414 297 448 
Resume: http://au.linkedin.com/in/bobjan 
Skype: bobjtls 
KakaoTalk: bobjtls 
http://www.cultconv.com 

 In line with the Australian anti-spam legislation, if you wish to receive no 
further email from me, please send me an email with the subject "No Spam"

> On 16 Sep 2020, at 01:30, Eric Shulman <elsdes...@gmail.com> wrote:
> 
>> On Tuesday, September 15, 2020 at 5:44:56 AM UTC-7, Bob Jansen wrote:
>> How can I check if a parameter passed to a macro is blank?
>> I have tried
>> \define purchased(name_id)
>> <$list 
>> filter="[tag[Artworks]!tag[Index]!<currentTiddler>search:name_id{[<<__name_id__>>]is[blank]then[XX]}sort[title]]}>&bull;
>>  <$link to={{!!artwork_id}}><$view field="title"/> <$view 
>> field="artwork_title"/></$link><br/></$list>
>> \end
>> but this does not work. If name_id is empty I want to search to look for the 
>> string XX which I know doesn't exist.
> 
> First, as you may have realized, the above doesn't work because you can't 
> "nest" filter syntax (i.e., you can't directly use a filter to describe 
> another filter's operand value)
> 
> To accomplish your goal, first calculate the desired operand value and assign 
> it to a variable.  Then reference the variable in the filter, like this:
> \define purchased(name_id)
> <$vars id={{{ [[$name_id$]!is[blank]else[XX]] }}}>
> <$list 
> filter="[tag[Artworks]!tag[Index]!match<currentTiddler>search:name_id<id>]">
>    &bull; <$link to={{!!artwork_id}}><$view field="title"> <$view 
> field="artwork_title"/></$link><br/>
> <$list>
> </$vars>
> \end
> 
> Alternatively, since you know that searching for [XX] will result in no 
> matching tiddlers, you could test for the blank value and just skip the $list 
> entirely:
> \define purchased(name_id)
> <$list filter="[[$name_id$]!is[blank]]" variable="not_blank">
>    <$list 
> filter="[tag[Artworks]!tag[Index]!match<currentTiddler>search:name_id[$name_id$]]">
>       &bull; <$link to={{!!artwork_id}}><$view field="title"> <$view 
> field="artwork_title"/></$link><br/>
>    <$list>
> </$list>
> \end
> The outer filter is being used as a conditional ("if name_id is not blank") 
> with the variable ("not_blank") used to avoid changing the value of 
> <<currentTiddler>>.
> Note: I like to use a variable name that summarizes the purpose of the 
> filter, but you could use any variable name (e.g., "foo") since you really 
> don't reference it anywhere.  
> 
> -e
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "TiddlyWiki" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/tiddlywiki/naMx9faSnRI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> tiddlywiki+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/ae75c768-803c-4bbb-9d71-20646a542e05o%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/D826E737-1030-451D-A46F-5045BAEF2809%40gmail.com.

Reply via email to