Problem passing Macro result as dictionary tiddler name in name: value pair

32 views
Skip to first unread message

Sakura Thompson

unread,
Jul 27, 2018, 2:42:51 PM7/27/18
to TiddlyWikiDev
Hi there, 
This is my first post to this group =)

I am using TW5 5.1.14 in a browser (Chrome)
I am having issues passing a macro result as a name (as a part of a name:value pair) to a dictionary tiddler

I have a Dictionary Tiddler, DTiddler_1

DTiddler_1
1: foo
2: bar
3: baz
(etc to 6)
A call from a test tiddler - {{DTiddler_1##1}} returns foo, as expected (so the Data Tiddler is formatted correctly) 
(testing each of 1 through 6 returns the expected value)

I have a macro, Rand_Num
A call from a test tiddler - <<RandNum max: '6'>> or <$macrocall $name="RandNum "  max="6" /> returns random numbers 1 through 6, as expected (so that macro works)

I am trying to return a random value from the data tiddler like this
{{DTiddler_1##<$macrocall $name="RandNum "  max="6" />}} or
{{DTiddler_1##<<RandNum max: '6'>>}}

but both return blank values, and no errors.

I've been browsing this board as well as https://tiddlywiki.com/ (MacroCallWidget, Data Dictionary, Text References, etc, etc) and searching Google, and can't seem to quite get it to work, or if it is even possible.

Any help or pointers in the right direction would be appreciated.
thanks!
Sakura

Mat

unread,
Jul 28, 2018, 8:01:51 AM7/28/18
to TiddlyWikiDev
Hi Sakura and welcome!

First off, your question is about basic TW usage i.e how to *use* TW by coding with wikitext so it is more suitable for the regular TiddlyWiki forum, not for the Dev forum.

Anyway, you have at least one (common) syntactic error: you're trying to use a macrocall (the RandNum) within the simplified transclusion i.e the {{...}}. 
General rule: You cannot nest such simplified syntax into one another, e.g {{ << >> }} 
Instead use the explicit transcludewidget.
Further, it is probably a good idea to wikify (i.e evaluate) that randnum macrocall before using it inside anything.
So:

<$wikify name=randy text=<<RandNum 6>> >
<$transclude $name="DTiddler_1" index=<
<randy>>/>
</$wikify>

NOTE that first RandNum macrocall - I don't know how the RandNum parameter list looks so it may be that the "max" parameter is in, say, position four in which case the macrocall would look like <<RandNum "" "" "" "6">> . 


<:-)

Mat

unread,
Jul 28, 2018, 8:05:00 AM7/28/18
to TiddlyWikiDev
Correction:

<$transclude $tiddler="DTiddler_1" index=<<randy>>/>

..or possibly even without the $ sign, not quite sure.

<:-)
Reply all
Reply to author
Forward
0 new messages