Text based on field value (Plus ">" or "< " math operators)

68 views
Skip to first unread message

Jake

unread,
Jun 27, 2020, 4:58:34 PM6/27/20
to TiddlyWiki
I've read this thing https://tiddlywiki.com/#Conditional%20Operators, but I'm still a bit confused which widgets to use: $text, $view, $list etc and which filters or operators...

Here's my question. 

1. For example, I have a field in some tiddler (tiddler1) called "state" and possible values in that field: "value1, value2, value3, value4, value5".

And I want to have a text in another tiddler (tiddler2) "good result" if the value of the field "state" in tiddler1 is value1 or value2, "bad result" if the value is value3 or value4 and "N/A" if the value is value5 or absent... how to do that?

2. And the second question, supplementing the first one: what if I want the resulting text ("good result", "bad...") to be a transclusion of other tiddlers (e.g. tiddlertext1, tiddlertext2, tiddlertext3)?

3. Plus one more... I wonder if there are operators ">" (larger) and "<" (smaller) in TW? For example if I want to have one text in some tiddler if the field value in another tiddler is larger then X and another text if it is smaller then Y?
I checked mathematics Operators here: https://tiddlywiki.com/#Conditional%20Operators but couldn't find the needed ones.

Jake

unread,
Jun 27, 2020, 6:54:33 PM6/27/20
to TiddlyWiki
After a bit of trying I came to understanding, that for single value this might work:

for text:
<$set name="myVariable" filter="[title[tiddler2]state[value1]then[good result]else[bad result]]">
<$text text=<<myVariable>>/>
</$set>

for another tiddler transclusion:
<$set name="myVariable" filter="[title[tiddler2]state[value1]then[tiddlertext1]else[tiddlertext2]]">
<$transclude tiddler=<<myVariable>> />
</$set>

though 3rd question remains anyway.

Xavier Cazin

unread,
Jul 12, 2020, 12:50:51 AM7/12/20
to tiddl...@googlegroups.com
Hi Jake,

You might want to look at the brand new compare operator: https://tiddlywiki.com/#compare%20Operator

-- Xavier


--
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/1729f479-77a8-4ce5-831d-c73d0b045071o%40googlegroups.com.

Jake

unread,
Jul 12, 2020, 1:05:19 AM7/12/20
to TiddlyWiki
 
You might want to look at the brand new compare operator: https://tiddlywiki.com/#compare%20Operator
 
Yeah-yeah. Thanks, Xavier! I found that some time ago. 
Reply all
Reply to author
Forward
0 new messages