[tw5] Re: Confusion on variables and parameters

2020-11-02 Thread Jon Dyer
Thank you very much for the explanation! This was very helpful.


On Monday, November 2, 2020 at 11:57:27 AM UTC-7, Mark S. wrote:
>
> The $variable$ variables only work with parameters from the macro -- you 
> can't assign them inside the macro.
>
> For variables that you create, you have to use the <> 
> nomenclature, except inside a filter expression in which case you can use 
> operator nomenclature.
>
> Just to confuse things more, inside your macro you could also refer to the 
> parameters like this
>
> <<__title__>>  and <<__label__>>
>
> This will get the default the way you want. I'm not sure why you're using 
> the text widget instead of just placing the text, but anyways ...
>
> \define mymac(title,label)
>
> <$text text="""Title: $title$"""/>
> 
> <$text text="""Label: $label$"""/>
> 
>
> <$set name="label" filter="$label$" value="$label$" 
> emptyValue="""$title$""">
> <$text text="""Title: $title$"""/>
> 
> <$text text="""Label: """/>
> <$text text=<>/>
>
> 
>
> \end
>
> <>
>
>
>
> On Monday, November 2, 2020 at 9:53:13 AM UTC-8, Jon Dyer wrote:
>>
>> I think I'm not understanding something essential about access to 
>> variables vs. params in macros and Wikitext. Suppose in a macro I'm writing 
>> I want one variable to default to the value of another if it isn't present. 
>> I've tried to use the SetWidget to make this work, but no matter what I try 
>> I can't seem to overwrite the parameter value with what I have in the 
>> <$set...> part. Can you tell what I'm doing wrong?
>>
>> For a concrete example:
>>
>> \define mymac(title,label)
>>
>> <$text text="""Title: $title$"""/>
>> 
>> <$text text="""Label: $label$"""/>
>> 
>>
>> <$set name="label" filter="$label$" value="$label$" 
>> emptyValue="""$title$""">
>> <$text text="""Title: $title$"""/>
>> 
>> <$text text="""Label: $label$"""/>
>> 
>>
>> \end
>>
>> <>
>>
>>

-- 
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/1750f4c2-eb1f-493a-945c-3cb9eaf833d3o%40googlegroups.com.


[tw5] Re: Confusion on variables and parameters

2020-11-02 Thread 'Mark S.' via TiddlyWiki
The $variable$ variables only work with parameters from the macro -- you 
can't assign them inside the macro.

For variables that you create, you have to use the <> 
nomenclature, except inside a filter expression in which case you can use 
operator nomenclature.

Just to confuse things more, inside your macro you could also refer to the 
parameters like this

<<__title__>>  and <<__label__>>

This will get the default the way you want. I'm not sure why you're using 
the text widget instead of just placing the text, but anyways ...

\define mymac(title,label)

<$text text="""Title: $title$"""/>

<$text text="""Label: $label$"""/>


<$set name="label" filter="$label$" value="$label$" 
emptyValue="""$title$""">
<$text text="""Title: $title$"""/>

<$text text="""Label: """/>
<$text text=<>/>



\end

<>



On Monday, November 2, 2020 at 9:53:13 AM UTC-8, Jon Dyer wrote:
>
> I think I'm not understanding something essential about access to 
> variables vs. params in macros and Wikitext. Suppose in a macro I'm writing 
> I want one variable to default to the value of another if it isn't present. 
> I've tried to use the SetWidget to make this work, but no matter what I try 
> I can't seem to overwrite the parameter value with what I have in the 
> <$set...> part. Can you tell what I'm doing wrong?
>
> For a concrete example:
>
> \define mymac(title,label)
>
> <$text text="""Title: $title$"""/>
> 
> <$text text="""Label: $label$"""/>
> 
>
> <$set name="label" filter="$label$" value="$label$" 
> emptyValue="""$title$""">
> <$text text="""Title: $title$"""/>
> 
> <$text text="""Label: $label$"""/>
> 
>
> \end
>
> <>
>
>

-- 
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/4084d0e9-6535-4f2a-9772-9fbb76de4cdfo%40googlegroups.com.