Hi Tobias,
I've been playing with eval, and I have the basics up and working.
As an exercise I am aiming to work out how much it would cost get all your
calories from a particularly cheep bag of chapati flour (£3 for 10kg!): I
I can create tiddler fields and eval them, but how would I store an eval in
a tiddler field?
Then, in another eval, I would calculate the cost of meeting the calorie
requirement with the flour. My thinking is that it would be good to store
evals in fields along with data used to calculate that eval
Should I be trying to do this, or is there a better way?
Here is the contents of a tiddler I created on your plugin site:
Total energy required: <$edit-text tiddler="Carbo-needs"
field="kcalDay"tag="input" placeholder="enter energy kcal per day"
default="2,500"/>
Percent from carb: <$edit-text tiddler="Carbo-needs"
field="Carbo-percent"tag="input" placeholder="percent" default="45"/>
----
```
<$set name="CostPerKilo"
filter="[[]eval[{{Carbo-needs!!kcalDay}}*{{Carbo-needs!!Carbo-percent}}]]">
cals from carbs = <<CostPerKilo>> kcal
</$set>
```
<<<
<$set name="CalsFromCarbs"
filter="[[]eval[{{Carbo-needs!!kcalDay}}*{{Carbo-needs!!Carbo-percent}}]]">
cals from carbs = <<CalsFromCarbs>> kcal
</$set>
<<<
How to write CalsFromCarbs variable to a tiddler field
Alex
On 20 December 2015 at 10:30, Tobias Beer <[email protected]> wrote:
> Went jogging this morning and came back with another nice idea.
>
> Now, as of version 0.5.7
> <https://github.com/tobibeer/tw5-setvars/releases/tag/0.5.7> of
> tobibeer/setvars <http://tobibeer.github.io/tw5-plugins/#setvars>,
> you can refer to variables previously declared in the same setvars widget
> instance.
>
> Get the update from the usual place:
>
> http://tobibeer.github.io/tw5-plugins/#setvars
>
> Here's a macro that shows how that works:
>
> *This macro routes a link to tiddlywiki.com <http://tiddlywiki.com> should
> there not be a local tiddler by that name while also allowing you to use a
> pretty title:*
>
>
> \define route(title,pretty)
> <$setvars
> _exists="[[$title$]is[tiddler]]"
> _not="[[$title$]!is[tiddler]]"
> title="if( \$pretty$\ ? \$pretty$\ ) || \$title$\"
> link="
> if( [exists] ? \[[\title\|$title$]]\ ) ||
> if( [not] ? \[ext[\title\|http://tiddlywiki.com#$title$]]\ )">
> <<link>>
> </$setvars>
> \end
>
>
> *Note: *Notice how the link variable refers to the title variable
> declared before it!
>
> <<route TextReferences "text-reference">>
>
> text-reference <http://tiddlywiki.com/#TextReferences>
>
> Best wishes,
>
> Tobias.
>
> --
> 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/85d4b6a3-5b96-4920-aae5-d30840efcb95%40googlegroups.com
> <https://groups.google.com/d/msgid/tiddlywiki/85d4b6a3-5b96-4920-aae5-d30840efcb95%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
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/CALc1hYef7zk3MZDfuZwr4esUEviFMTWGP87%3DfU0Shw_7AiJ0-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.