On Tuesday, November 3, 2020 at 1:54:31 PM UTC-8, Bhilhanan Jeyaram wrote:
>
> A tiddler "Tiddler 2" has a field "depends-on" with value "[[Tiddler 1]]
> [[Tiddler 3]]". Each each these two tiddlers has a field "sequence". Let's
> say "Tiddler 1":sequence=1 and "Tiddler 3":sequence=2. I'm trying to parse
> the list of "depends-on" and get the max value of "sequence" and then
> increment that number by 1 and assign that value to "Tiddler 2". In this
> example "Tiddler 2" will have the "sequence" value assigned as 3
>
You will need to use a $button widget to modify a tiddler and set a field
value.
Place the following into Tiddler 2:
<$button> set sequence
<$action-setfield sequence={{{
[enlist{!!depends-on}get[sequence]nsort[]last[]add[1]] }}} />
</$button>
Notes:
* enlist{!!depends-on} gets the list of tiddlers that the current tiddler
depends on
* get[sequence] gets the sequence field value from each of those tiddlers
* nsort[] does an ascending numeric sort of the sequence numbers
* last[] gets the last number (i.e., the max value)
* add[1] increments that number
* the result of the entire filter (the new number) is then assigned to the
sequence field of the current tiddler
Note: you can put the above button into a separate tiddler (e.g.,
"SetSequenceNumber") and then transclude it using:
{{||SetSequenceNumber}}
Alternatively, you could tag the SetSequenceNumber tiddler with
$:/tags/Macro, containing:
\define SetSequenceNumber()
<$button> set sequence
<$action-setfield sequence={{{ [enlist{!!depends-on}get[sequence]nsort[]
last[]add[1]] }}} />
</$button>
\end
Then, to invoke the macro, you would add the following in "Tiddler 2"
<<SetSequenceNumber>>
enjoy,
-e
--
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/fb2a9b17-9b50-4e48-873f-ac626f583368o%40googlegroups.com.