Bob,

My first observation from your post is the filter contains;

   - id*{[<<__*name_id__*>>]*is[blank]then[XX]*}sort[title]]}*

Which seems to include multiple syntax issues. 

Something that took me years to learn which may help if you is;

In wiki text we can also use html which uses <htmltag></htmltag> so to 
allow macros we use <<macroname>> and for widgets we use <$widgetname> for 
transclusion we use {{ tiddlername }}

When you use a filter, where html is not possible, you do not need to 
differentiate between <htmltag> and <<macroname>>, in fact both are illegal 
in filters,  etc.. so we remove a layer of brackets
The following is appropriate in a filter

   - <varname>  (not you can use <macroname> but not <macroname params> in 
   filters
   - {tiddlername} returns content in tiddlername
   - {!!fieldname} returns content in currenttiddlers fieldname
   - Because a set of brackets already delimits a varname Rather than 
   operator[<varname>] we use operator<varname>
   - Keep in mind we can use substitutions in filters $param$ and 
   $(varname)$  $(*Not retested recently by me*)$ however (substitutions 
   need not contain delimiters) so we use operator[$varname$]


A Quick note is that <<__...__>> 
see https://tiddlywiki.com/#Macro%20Definitions%20in%20WikiText

<<__...__>> Parameter-as-variable access to a parameter defined in the 
macro parameters list
There are a few cases where using a parameter named in the \define pragma, 
normally in the form $parameter$, is not what you need

   - which simply substitutes $parameter$ with the value in the parameter, 
   eg text="$parameter$"

This Parameter-as-variable method simply lets you pass that parameter as if 
it were a variable 

   -  eg text=<<__parameter__>> There are a FEW cases where this was 
   essential. 


however I tend to find more value using the substitution forms in macros 
because there is less need to concatenate values

   - eg; tooltip="This is the $tooltipparam$  works"
   - And access a variable and use as substituton $(varname)$ (only in 
   macro definitions)

The exception to this is demonstrated in this example where I imediatly 
convers parameters into variables to allow defaults to be computed.

\define macroname(input-parm)
<$set name=input-parm value="$input-parm$" emptyValue=<<othermacrofordefault
>> >
   Use input-parm=<<input-parm>> as a result I will not use the original 
$input-parm$ or the original <<__input-parm__>> in here
</$set>
\end
This method allows for more sophisticated or computed default values, and 
relies on emptyValue or in $list emptyMessage

So I do not mislead you another way to handle defaults for parameters that 
are *literal strings* is as follows
\define macroname(input-parm:"defaultstring")
Use the original $input-parm$ or the original <<__input-parm__>> in here
\end


Regards
Tones

On Wednesday, 16 September 2020 08:00:33 UTC+10, Dr Bob Jansen wrote:
>
> 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 <[email protected] <javascript:>> 
> 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 
> [email protected] <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/ae75c768-803c-4bbb-9d71-20646a542e05o%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/tiddlywiki/ae75c768-803c-4bbb-9d71-20646a542e05o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/8bec3fc2-c6c5-493c-bc2c-563a68af6ef1o%40googlegroups.com.

Reply via email to