Macro

75 views
Skip to first unread message

vinvi...@gmail.com

unread,
Dec 4, 2020, 11:50:45 AM12/4/20
to TiddlyWiki
Hello,

I have a question about creating a macro.

I have to make a lot of buttons in my wiki and I have this code for a button for creating a new tiddler; (It works fine.)

`<div style="float:left;"><$button><$action-sendmessage $message="tm-new-tiddler" title=<<now format:"TITLE-TIDDLER-HERE">> tags="TAG-NAME-HERE" tags show="TAG-NAME-HERE" text="TEXT-HERE" comment="FIELD-COMMENT-HERE"/><span style="color:blue;">''BUTTON-NAME-HERE''</span></$button></div>`

How do I convert the above code into a macro?

This is my attempt, but I can't get it done:

`\define NEW-TIDDLER(now format:"XXX" 
tags:"XXX" tags show:"XXX" text:"XXX" comment:"XXX")
<div style="float:left;"><$button><$action-sendmessage $message="tm-new-tiddler" title=<<$now format:$>> $tags$ $tags show$ $text$ $comment$/><span style="color:blue;">''BUTTON-NAME-HERE''</span></$button></div>
\end

<<NEW-TIDDLER
now format:"XXX" 
tags:"XXX" 
tags show:"XXX" 
text:"XXX" 
comment:"XXX" 
">>`

Thank you,



Mark S.

unread,
Dec 4, 2020, 1:27:55 PM12/4/20
to TiddlyWiki
You can't use a parameter with spaces in the name (e.g., you can't use "now format" as a parameter). You also can't create field names with spaces in them.

Substituting hyphens for spaces, and a few other changes, this might be closer to what you want:

\define NEW-TIDDLER(now-format:"XXX" 
tags:"XXX" tags-show:"XXX" text:"XXX" comment:"XXX")
<div style="float:left;"><$button><$action-sendmessage $message="tm-new-tiddler" title=<<now $now-format$>> tags="""$tags$""" tags-show="""$tags-show$""" text="""$text$""" comment="""$comment$"""/><span style="color:blue;">''BUTTON-NAME-HERE''</span></$button></div>
\end

<<NEW-TIDDLER
now-format:"XXX" 

TW Tones

unread,
Dec 4, 2020, 6:21:41 PM12/4/20
to TiddlyWiki
Do explain why you want a macro,
Is it for reusable code?

I will provide a different solution to yours once I understand more. I did learn by reviewing the core buttons in tiddlywiki, search the shadow tiddlers, they can be simplified further.

It seems to me in this case the macro is almost as "verbose" as the button widget. Sometimes pasting a snippet is just as quick.

I also tend get many of the values used from elsewhere, such as fields and variables, you will need to use the macrocall widget to do this.

Regards
Tones
Reply all
Reply to author
Forward
0 new messages