Guille Rmo

Thanks for sharing your work. Increments have being difficult in 
TiddlyWiki, this works good as a button counter.

You may be interested in the new range operator coming in V 5.1.18

Regards
Tony

On Thursday, 23 August 2018 04:14:47 UTC+10, Guille Rmo wrote:
>
> I found math.js 
> <https://groups.google.com/forum/#!topic/tiddlywiki/cPq72e4x1f8> plugin 
> for tw a while ago. However I didn't managed to do what I wanted with it. I 
> wanted to set a field value with a math expression. I remember I managed to 
> do it with a macro and a $set variable, but I think that is not very clean. 
> Instead, I thought that making an alternative action-setfield widget was 
> the right thing to do. So I took @mklauber plugin and wrote the widget.
>
> See the following examples to get an Idea of what is possible with this:
>
> This button raises the field "test2" to the power of 2 each time it is 
> clicked:
>
> <$button>
> <$action-setfield-mathjs $tiddler=<<currentTiddler>> $field="test2" 
> $eval="test2^2" />
> Click to raise <b>{{!!test2}}</b> to the power of 2
> </$button>
>
> You can also manipulate data tiddlers. In the following, the data tiddler 
> [[ExampleData]] is updated with math operations:
>
> <$button>
> <$action-setfield-mathjs $tiddler="ExampleData" $index="y" $eval="y+1" />
> Click to increment y ( {{ExampleData##y}} )
> </$button>
>
> <$button>
> <$action-setfield-mathjs $tiddler="ExampleData" $index="x" $eval="x+1" />
> Click to increment x ( {{ExampleData##x}} )
> </$button>
>
>
> The tiddler fields or the data tiddler indexes are set as the math.js 
> scope, so you can use the names in the math.js expressions.
>
> The main motivation for this was having a simple increment button :) But 
> it is quite powerful. Hope you can come up with great use cases for this.
>
> The demo is here: 
> https://cdn.rawgit.com/Guitlle/tiddly-mathjs/build/tmp.html
>
>
>

-- 
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/59023aaf-ad17-4d5f-abb4-0a476a3f8522%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to