Hi Mark,

 Yes, the first loop is not necessary in all cases except one, if a user or
another action sets a third value in that index of data tiddler.
 As toggle is a listops operator, it does not toggle the whole value, so
you may see your code has appended a value to the list of
 current values.
 This issue happened when I tried to use the code for a page control button
to switch the day/light palette.

Best wishes
Mohammad


On Sat, Jan 2, 2021 at 12:37 AM 'Mark S.' via TiddlyWiki <
[email protected]> wrote:

> Hi Mohammad!
>
> Interesting! But the first list loop doesn't seem to be necessary.
>
> On Friday, January 1, 2021 at 6:46:14 AM UTC-8 Mohammad wrote:
>
>> I use data tiddler (Json tiddler) to store settings and configs of a
>> plugin or other tools.
>>
>> Below is an example how to toggle/switch a value in a data tiddler (e.g.
>> myTest)
>> It uses a pair of  *key*: *mode* and *value*: *author-mode /
>> presentation-mode*
>>
>> *Go to *https://tiddlywiki.com/ and create a tiddler and give a try!
>>
>>
>> <$vars tid="myTest">
>>
>> <$button>Toggle
>> <$list
>> filter="[<tid>getindex[mode]!match[author-mode]!match[presentation-mode]]">
>> <$action-setfield $tiddler=<<tid>> $index="mode" $value=""/>
>> </$list>
>>
>> <$action-listops $tiddler=<<tid>> $index="mode"
>> $subfilter="+[toggle[author-mode],[presentation-mode]]" />
>> </$button>
>>
>> ;Result
>> :<$text text={{{[<tid>getindex[mode]]}}}/>
>> </$vars>
>>
>>
>>
>>
>> Best wishes
>> Mohammad
>>
> --
> 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/15017eed-b72e-4848-bf2c-f7223fcd062fn%40googlegroups.com
> <https://groups.google.com/d/msgid/tiddlywiki/15017eed-b72e-4848-bf2c-f7223fcd062fn%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/CAAV1gMBTV6mXimXEnRRNOGF_92QZp0YbxG5tCcvuhutv4c%2BeFg%40mail.gmail.com.

Reply via email to