How to pass a variable to a macro

59 views
Skip to first unread message

vpl

unread,
Aug 21, 2019, 9:48:28 AM8/21/19
to TiddlyWiki
Hi

A stupid question ... but how to pass a variable to a macro in wikitext
I can't find any example

<$button>
<$set name="myVariable" value={{!!date-format}}></$set>
<$action-setfield $tiddler="$:/plugins/vpl/jazzbokMem/DbActivity"; $index=<<now $(myVariable)$ >> $value="hello" />
Test
</$button>

My date-format field contains "YYYY-0MM-0DD:hh:0mm:0ss"
When I click on the button this action populate the data-tiddler with the following content
{
"$(myVariable)$": "hello"
}

Where I'm expecting
"2019-08-21:15:20:09": "hello"

Any idea would help me a lot

Thanks for your support

Vpl
",

Mark S.

unread,
Aug 21, 2019, 11:29:33 AM8/21/19
to TiddlyWiki
Text substitution (e.g. $(myvariable)$ ) only happens inside of macros. So you need to define a macro.

This version seems to work:

\define mymacro() <$action-setfield $tiddler="$:/plugins/vpl/jazzbokMem/DbActivity"  $index=<<now $(myVariable)$ >> $value="hello" />


<$button>
<$set name="myVariable" value={{!!date-format}}></$set>
Test<<mymacro>>
</$button>

Good luck!

vpl

unread,
Aug 21, 2019, 11:59:23 AM8/21/19
to TiddlyWiki
Ah OK !! 

Thanks very much
Reply all
Reply to author
Forward
0 new messages