Calculating transcluded tiddler and conditionals

51 views
Skip to first unread message

W Yan

unread,
Nov 8, 2020, 1:26:52 AM11/8/20
to tiddl...@googlegroups.com
Hi, I've been trying to achieve something using state tiddlers, but couldn't make it work.
 
1. How could I calculate something based on transcluded tiddler? I have a state tiddler that contains dynamic values and I want to use it with calculated output; Something like {{Tiddler}}/2. I tried <$text text={{{ {{Tiddler}} +[divide[2]] }}}> but it didn't work.
 
2. It is more like a mathematic question, but will it be possible to get a decreasing value when state tiddler is increasing? For example, when state tiddler value is ...10, 12, 14... I would like to get calculated output of ...8, 7, 6...
 
3. I'd like to set a text to show when a state tiddler is empty, and when state tiddler contains a value it shows that value instead of default text. So basically {{stateTiddler}}is[empty]then[defaultText]else{{stateTiddler}} something like that.
 
I would appreciate any help.

Eric Shulman

unread,
Nov 8, 2020, 2:14:41 AM11/8/20
to TiddlyWiki

On Saturday, November 7, 2020 at 10:26:52 PM UTC-8, W Yan wrote:
1. How could I calculate something based on transcluded tiddler? I have a state tiddler that contains dynamic values and I want to use it with calculated output; Something like {{Tiddler}}/2. I tried <$text text={{{ {{Tiddler}} +[divide[2]] }}}> but it didn't work.

* The syntax surrounding a "filtered transclusion" is: {{{ [...filter goes here...] }}}
* Within filters, use SINGLE curly braces to fetch the contents of a tiddler.
* Since there is no matching </$text>, use "/>" to end the $text widget.

Thus:
<$text text={{{ [{Tiddler}divide[2]] }}} />

2. It is more like a mathematic question, but will it be possible to get a decreasing value when state tiddler is increasing? For example, when state tiddler value is ...10, 12, 14... I would like to get calculated output of ...8, 7, 6...

The mathematical relationship between these numbers is not clear.  If you can provide an equation that shows how each input value gives the corresponding output value, I can probably show you how to write it as a filter.
 
3. I'd like to set a text to show when a state tiddler is empty, and when state tiddler contains a value it shows that value instead of default text. So basically {{stateTiddler}}is[empty]then[defaultText]else{{stateTiddler}} something like that.

* The keyword for the is[...] filter should be "blank", not "empty".  Thus:
<$text text={{{ [{stateTiddler}is[blank]then[defaultText]else{stateTiddler}] }}} />

* You can simplify the above as:
<$text text={{{ [{stateTiddler}else[defaultText]] }}} />

enjoy,
-e 

W Yan

unread,
Nov 8, 2020, 4:31:18 AM11/8/20
to tiddl...@googlegroups.com
Thank you so much for the answers! I've just tried them and they work great.
 
W Yan
 


08.11.2020, 10:14, "Eric Shulman" <elsd...@gmail.com>:
--
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 tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/8055b51a-7fb0-4e69-b471-966d30891823o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages