Count macro with letters

64 views
Skip to first unread message

Magnus

unread,
Jul 28, 2018, 6:12:19 PM7/28/18
to TiddlyWiki
I have a count.macro like this:

<$count filter="[genus{!!caption}] -[rank[genus]]"/> (in parent tiddler gives a number for every tiddler with the field rank with content not genus and the field genus same as the parents field caption)

But every other instans where I use numbers I use letters up to 12 (one, two, ... twelve instead of 1,2, ...12) since that is the my universitys prefererad way. How would I go about to change my macro to accommodate for this? Some kind of $list reveal?

Thanks in advance
/magnus

Mat

unread,
Jul 28, 2018, 6:34:28 PM7/28/18
to TiddlyWiki
I interpret your question to be; how can I show the word "twelve" when I got the number 12 as output.

You can use a dictionary tiddler with:

1:one
2:two
...


Then in your tiddler

\define getmyword() {{mydictionary##$(number)$}}

<$list filter="...count[]]" variable=number>
<<getmyword>>
</$list>



<:-)

Mark S.

unread,
Jul 28, 2018, 6:38:28 PM7/28/18
to TiddlyWiki
There are different approaches. Here's one:

<$list filter="1 2 3 4 11" variable="number">
<$list filter="1 A 2 B 3 C 4 D 5 E 6 F 7 G 8 H 9 I 10 J 11 K 12 L +[after
<number>]" variable="letter">
<
<letter>>
</$list>

The outer list layer is just to generate examples (I don't have a database of genus counts handy). The inner list does the conversion.


HTH
-- Mark

Eric Shulman

unread,
Jul 28, 2018, 7:12:21 PM7/28/18
to TiddlyWiki
On Saturday, July 28, 2018 at 3:12:19 PM UTC-7, Magnus wrote:
Try this:
\define words() one two three four five six seven eight nine ten eleven twelve

<$set name="num" filter="[genus{!!caption}] -[rank[genus] +[count[]]">
<$list filter="[enlist<words>nth<num>]" />
</$set>

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals

Mohammad

unread,
Jul 30, 2018, 1:43:34 PM7/30/18
to TiddlyWiki
Eric,
here I have an undefined v, what it returns one

\define words() one two three four five six seven eight nine ten eleven twelve

<$list filter="[enlist<words>nth<v>]" variable="num">
<<num>>
</$list>


Mohammad
Reply all
Reply to author
Forward
0 new messages