String concatenated to macro as attribute of tag

56 views
Skip to first unread message

Ed Heil

unread,
May 26, 2020, 5:01:34 PM5/26/20
to TiddlyWiki
This has been driving me batty and makes me hope there is a simple solution I'm missing.

I have a button which is supposed to create a new tiddler named "Dream Log YYYY-MM-DD" tagged with the current tiddler.

It looks like this and NEARLY works:

\define dream-log-button()
<$button>New Dream Log
<$action-sendmessage $message="tm-new-tiddler" title=<<now "Dream Log YYYY-0MM-0DD">> tags="[[$(currentTiddler)$]]">
</$button>
\end

<<dream-log-button>>

The only problem is, if you click the button after noon, it creates a tiddler titled "Drepm Log 2020-05-26" because "am" is significant to the "now" macro.

I've been going in circles trying to figure out how to concatenate the string "Dream Log " to the result of the macro call <<now "YYYY-0MM-0DD">> and feed that into the "title" attribute of the action-sendmessage.  But I'm not quite getting it.  I figure I must be missing something simple, since this seems like a simple thing.

I've tried this:

\define dream-log-title()
Dream Log <<now "YYYY-0MM-0DD">>
\end
\define dream-log-button()
<$button>New Dream Log
<$action-sendmessage $message="tm-new-tiddler" title=<<dream-log-title>> tags="[[$(currentTiddler)$]]">
</$button>
\end


but that just gives me a tiddler named "Dream Log <<now "YYYY-0MM-0DD">>"

I've been banging around switching <<>> for <$macrocall>s, creating variables and trying to interpolate them into macros, and so on, but so far haven't got it right.

Can somebody point me in the right direction?

Mark S.

unread,
May 26, 2020, 5:25:23 PM5/26/20
to TiddlyWiki
Yes, concatenation can be confusing. Often you have to take the different pieces, and then put them together in a macro.
This version seems to work:

\define dream-log-title()
Dream Log $(today)$
\end
\define dream-log-button()
<$vars today=<<now "YYYY-0MM-0DD">> >

<$button>New Dream Log
<$action-sendmessage $message="tm-new-tiddler" title=<<dream-log-title>> tags="[[$(currentTiddler)$]]">
<
/$button>
</
$vars>
\end

<<dream-log-button>>


TonyM

unread,
May 26, 2020, 7:29:37 PM5/26/20
to TiddlyWiki
Ed,

I would also enhance Marks Solution with one more field in the new tiddler actionWidget
log-date=<<now "YYYY0MM0DD0hh0mm0ss0XXX">>

<$action-sendmessage $message="tm-new-tiddler" title=<<dream-log-title>> tags="[[$(currentTiddler)$]]" log-date=<<now "YYYY0MM0DD0hh0mm0ss0XXX">> >

Then it will be far easier to interrogate the date of log entries going forward. You could even change the title to be more reader friendly because you have the real and editable date in the log-date field.

Regards
Tony

Ed Heil

unread,
May 26, 2020, 9:57:58 PM5/26/20
to TiddlyWiki
Thanks, folks!  I thought I had tried the "feed it into a macro through a variable" trick but apparently I didn't quite get it right.  I like the idea of a more precise and specific log field, too, that's great!
Reply all
Reply to author
Forward
0 new messages