Variable substitution in macros: HowTo?

105 views
Skip to first unread message

Niels Bjerre

unread,
Aug 24, 2017, 8:48:54 AM8/24/17
to TiddlyWiki
I have a variable that render fine. E.g.:
<<newdescription>>    render as "This is the new description" 

The newdescription is from a stateTidler:  {{stateTidler!!description}}

If I use the variable in a macro that creates a new tiddler (e.g. $action-sendmessage)

==> the variable (<<newdescription>>) is shown as "{{stateTidler!!description}}" in the new tiddlers field.

I believe I have searched for help everywhere and tried everything!? 

Thanks in advance
Niels

Niels Bjerre

unread,
Aug 24, 2017, 9:47:23 AM8/24/17
to TiddlyWiki
It does not matter if I use 
  1. \define,
  2. $set OR
  3. $var
.. to define the variable: newdescription

Mark S.

unread,
Aug 24, 2017, 9:55:50 AM8/24/17
to TiddlyWiki
Without seeing your work, it's hard to know what's going on. This for instance, works:

\define maketid()
<$button>
<$action-sendmessage $message="tm-new-tiddler" title="$(newdescription)$" tags="OneTag [[Another Tag]]" text=<<now "Today is DDth, MMM YYYY">>/>
New Tiddler
</
$button>
\end

<$vars newdescription={{stateTidler!!description}}>
<<maketid>>
</$vars>

Good luck,
Mark

Niels Bjerre

unread,
Aug 24, 2017, 10:34:23 AM8/24/17
to TiddlyWiki
Thank You
Yes - but ..... Why does this not work: Where state titdler is generated with "qualify 'new-tiddler'" to make it multiuser safe

\define maketid()
<$button>
<$action-sendmessage $message="tm-new-tiddler" title="$(tidlernewtitle)$" tags="OneTag [[Another Tag]]" text=<<now "Today is DDth, MMM YYYY">>/>
New Tiddler
</
$button>
\end


<$set name="statetiddler" value=<<qualify 'new-tiddler'>>>
<$edit-text tiddler=<<statetiddler>> field='newtitle' placeholder="Title" tag="input" default=""/>


<$vars tidlernewtitle={{stateTidler!!newtitle}}>
<<maketid>>
</$vars>
</
$set>

Mark S.

unread,
Aug 24, 2017, 11:07:32 AM8/24/17
to TiddlyWiki
You need another macro to concatenate the name and field from which you want to retrieve the new tiddler name. And you need the wikify widget to turn that transclusion into a value. Like this:

\define editedname() {{$(statetiddler)$!!newtitle}}

\define maketid()
<$button>
<$action-sendmessage $message="tm-new-tiddler" title="$(tidlernewtitle)$" tags="OneTag [[Another Tag]]" text=<<now "Today is DDth, MMM YYYY">>/>
New Tiddler
</
$button>
\end

<$set name="statetiddler" value=<<qualify 'new-tiddler'>>>
<$edit-text tiddler=<<statetiddler>> field='newtitle' placeholder="Title" tag="input" default=""/>

<$wikify name=tidlernewtitle text=<<editedname>> >
<<maketid>>
</$wikify>

</
$set>

It must have been possible to do this before the Wikify widget, but it's hard to imagine how.

Good luck,
Mark

Niels Bjerre

unread,
Aug 25, 2017, 2:56:00 AM8/25/17
to TiddlyWiki
Perfect - Thank You!
$wikify did the trick


Den torsdag den 24. august 2017 kl. 14.48.54 UTC+2 skrev Niels Bjerre:
Reply all
Reply to author
Forward
0 new messages