Hi Mark
in your below example type will be equal to "long" online inside else()
however inside the section {full code here 1} it won't actually the section
{cull code here 1} won't even be reached
Please tell me if I am mistaken
On Thursday, May 21, 2020 at 5:34:15 PM UTC+3, Mark S. wrote:
>
> But you can set a variable inside a macro:
>
> \define else()
> <$set name="type" value="long">
> <<type>>
> </$set>
> \end
> <$vars variable="variable">
> <$list filter="[<variable>length[]match[9]]" emptyMessage=<<else>>>
> <$set name="type" value="short">
> {full code here 1}
> </$set>
> </$list>
> </$vars>
>
> All that matters is that the alternate "else" does whatever task you want.
> The scope of all variables in TW is limited -- allways between two tags.
> Here a variable is set inside the emptyMessage, and then displayed so you
> an see that it was set and used.
>
> On Wednesday, May 20, 2020 at 9:19:59 AM UTC-7, Tony K wrote:
>>
>> I can't figure out how to set the value of a variable based on a specific
>> condition so, instead, I am writing the code twice
>>
>> e.g.
>>
>> <$list filter="[<variable>length[]match[9]]">
>> <$set name="type" value="short">
>> {full code here}
>> </$set>
>> </$list>
>> <$list filter="[<variable>length[]!match[9]]">
>> <$set name="type" value="long">
>> {full code here}
>> </$set>
>> </$list>
>>
>> this is not really efficient.
>>
>> I tried conditionally inserting the first line of the "$set" but it
>> didnt' work (as follows) even thought logically it should
>>
>> <$list filter="[<variable>length[]match[9]]">
>> <$set name="type" value="short">
>> </$list>
>>
>> <$list filter="[<variable>length[]!match[9]]">
>> <$set name="type" value="long">
>> </$list>
>>
>> {full code here}
>> </$set>
>>
>>
>> I am sure there is some kind of a workaround for this
>>
>> thanks for shedding any light
>>
>
--
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/3f43498a-8095-4c7c-8ee1-14bcb1db1e2d%40googlegroups.com.