Joshua's site says that the improved "indexes" filter will return all 
paths. So

IF you have the same number of entries for each nested group, then you can 
divide by that number and add one to get the next number in the sequence:

<$list filter="[[myData]indexes[]count[]divide[2]add[1]]" 
variable="nextnum">
... do stuff
</$list>

This example assumes 2 items per group.

The problem with this approach is that you might, at some time, delete an 
entry. So this approach only works if you never delete entries.

A more advanced approach would require you to add a "number" field to each 
nested group. If you had such an index, then you could write
a macro that would run through the entries, find the highest value and add 
one.

hth

On Wednesday, November 13, 2019 at 11:51:24 AM UTC-8, si wrote:

> Thanks for your help, that does the trick.
>
> In order to get a new numerical value for each level every time I press 
> the button I have used the MathyThing 
> <http://inmysocks.tiddlyspot.com/#MathyThing%20-%20action-increment%20Widget> 
> plugin to increment the number in a field called "number". It's a little 
> tenuous though because it will be easy in my use case to accidentally 
> overwrite this number.
>
> Do you know of a better way to this? e.g. a way to count the number of 
> bottom level entries in the JSONTiddler and add 1 or something?
>
> I've attached an example of what I have done.
>
> <$edit-text tiddler="$:/state/enter-text"/>
>
> <$button>
> <$wikify name=title-value text="<<currentTiddler>> [{{!!number}}]/Title" >
> <$wikify name=text-value text="<<currentTiddler>> [{{!!number}}]/Text" >
> <$wikify name=date-value text="<<currentTiddler>> [{{!!number}}]/Date" >
> <$action-increment $tiddler=<<currentTiddler>> $field=number $initial="0" 
> $increment="1"/>
> <$action-setfield $tiddler=myData $index=<<title-value>> 
> $value=<<currentTiddler>>/>
> <$action-setfield $tiddler=myData $index=<<text-value>> 
> $value={{$:/state/enter-text}}/>
> <$action-setfield $tiddler=myData $index=<<date-value>> $value=<<now>>/>
> </$wikify>
> </$wikify>
> </$wikify>
> Save
> </$button>
>
> Thanks again for your help.
>
> On Sunday, November 10, 2019 at 10:24:34 PM UTC, Mark S. wrote:
>>
>> Since you're writing to the same indexes on the same tiddler, it 
>> overwrites them.
>>
>> There's no tools in TW for handling nested data tidders, but you can use
>>
>> Joshua Fontany's JSON Mangler:
>>
>> https://joshuafontany.github.io/TW5-JsonMangler/
>>
>> Then you can make $index=level1/Title, $index=level2/Title, etc. and 
>> create nested data tiddlers.
>>
>> Good luck!
>>
>>

-- 
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/abdcf751-2208-4c8c-aeff-79b574d08eb5%40googlegroups.com.

Reply via email to