See this in action:

https://kookma.github.io/TW-Commander/

Thanks Mark.

--Mohammad

On Monday, February 18, 2019 at 7:29:00 PM UTC+3:30, Mark S. wrote:
>
>
> List widgets look deceptively like for-next loops in other languages, but 
> they don't work that way (or at least I don't think they do). At the moment 
> you click the button, there is essentially already a list of things -- a 
> snapshot -- that will be activated, and that list is not changed on the 
> fly. So you need to have a complete list of actions you will take before 
> you press the button. Or, another way to look at it, you can't change 
> things in tiddlers that will change the outcome of the filters. From time 
> to time I mention that javascript is easier. This is what I mean. In JS you 
> can run a loop that changes the conditions that terminate the loop.  Oh 
> well.
>
> Here's what I've come up with. It worked. Once. It first goes through and 
> makes a list of all the suffixes that will be created by your process. Then 
> it turns that list into a title list. Then it feeds the resulting list into 
> a filter that checks if there are more than one tiddlers (e.g. two 
> tiddlers) that will be impacted. If there are more than 1, than it does 
> nothing. Otherwise it does the changes. It probably needs to be cleaned up, 
> since there's bits I didn't end up using.
>
> HTH
>
> -- Mark
>
> \define suffix-actions()
> <$list filter="[tag[xx]suffix<sfx>]" variable="item">
>  <$action-setfield      $tiddler=<<item>> title=<<sfx>> />
>   <$action-deletetiddler $tiddler=<<item>> />
> </$list>
> \end
> \define makelink() [[$(newTitle)$]]
> \define makeregexp() ^.{$(n)$}$(sfx)$$
> \define generate-suffixes(myfilter, n:"0")
> <$list filter="[<__n__>] -0" variable=null>
> <$list filter=<<__myfilter__>> variable="item">
> <$list filter="""[<item>split[]rest[$n$]join[]]""" variable="newTitle">
> <$text text=<<makelink>>/>
> </$list>
> </$list>
> </$list>
> \end
> \define deprefix-title(myfilter,num)
> <$button>
> Delete $num$ chars
> <$vars n="$num$" >
> <$wikify text="""<<generate-suffixes myfilter:"$myfilter$" n:"$num$">>""" 
> name="outputs" output="formattedtext" mode="block">
> <$list filter="[subfilter<outputs>]" variable="sfx">
> <$list filter="$myfilter$ +[suffix<sfx>limit[2]count[]regexp[2]]" 
> emptyMessage=<<suffix-actions>> variable="cnt">
> </$list>
> </$list>
> </$wikify>
>
> </$vars>
> </$button>
> \end
>
> <<deprefix-title "[tag[xx]]" "1">>
>
>
>
>

-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/ba9889b5-61f3-443d-98d8-946b4bf776d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to