macro within macro using macrocall

109 views
Skip to first unread message

Dave

unread,
Jun 30, 2018, 7:13:19 PM6/30/18
to TiddlyWiki
Hi, I'm struggling getting macrocall to work to allow me to use a macro within a macro

Here's what I originally wanted to do:

Given this macro (<<sliderO "*" "hello there">>)

\define sliderO(label,text)
<$set name=this value=$(currentTiddler)$ >
<$button popup="$:/state/<<this>>$label$" class="btn-invisible tw-slider">$label$</$button>
<$reveal type="match" text="" default="" state="$:/
state/<<this>>$label$" animate="yes">

$text$

</$reveal></$set>
\end

I wanted to call that macro with the following as the text:

 | ''resisted finger ext'' | <<rorlcheck resfingerext>> |


So the content would be revealed with the slider mechanism.  The problem is that you can't have a <<macro>> within a <<different macro>> I assume because of the "<<>>" repetition

----

The answer I presume from googling here is to use a macrocall, but for the life of me I can't seem to get it to work

I tried setting the content as both a macro and a variable:


\define motor2ndorder()
 | ''resisted finger ext'' | <<rorlcheck resfingerext>> |

\end

<$macrocall name=sliderO label="Motor 2nd Order" text=<<motor2ndorder>>/>

and

<$vars text="""
 | ''resisted finger ext'' | <<rorlcheck resfingerext>> |
"""></$vars>

<$macrocall name=sliderO label="Motor 2nd Order" text=<<text>>/>

but neither of those is working :(

any suggestions?

Mark S.

unread,
Jun 30, 2018, 7:19:56 PM6/30/18
to TiddlyWiki
I don't know if this will fix your problem (without actually testing) but one of the things that will drive you crazy (or at least me) with TW5 widgets is the inconsistent attributes/parameters.

In this case, you need to call <$macrocall> with attribute "$name", not "name" . Pretty much every time you use (or I use) a widget, I have to double check the syntax at tiddlywiki.com, because it's different for different widgets. For instance, if you had been invoking the "<$set> widget, then the attribute really would have been "name".

HTH
-- Mark

Dave

unread,
Jun 30, 2018, 8:16:01 PM6/30/18
to TiddlyWiki
Thank you, that was it.

Loading the content as a macro at the beginning of the tiddler and referring to it in the macrocall worked.

:)

PMario

unread,
Jul 1, 2018, 5:52:27 AM7/1/18
to TiddlyWiki

On Sunday, July 1, 2018 at 1:19:56 AM UTC+2, Mark S. wrote:
I don't know if this will fix your problem (without actually testing) but one of the things that will drive you crazy (or at least me) with TW5 widgets is the inconsistent attributes/parameters.

It's not inconsistency, but needed.
 
In this case, you need to call <$macrocall> with attribute "$name", not "name" . Pretty much every time you use (or I use) a widget, I have to double check the syntax at tiddlywiki.com, because it's different for different widgets. For instance, if you had been invoking the "<$set> widget, then the attribute really would have been "name".

  • The macrocall widget needs to know which macro should be used: $name
  • Macros can have named parameters, eg: name ...

So the <macrocall> widget needs to know, which name is a parameter for the macro and which one is the macro $name.

have fun!
mario

Mohammad

unread,
Jul 1, 2018, 8:46:08 AM7/1/18
to TiddlyWiki
Hi Mark,
 That't true! The other think is the many logic you can do the same thing with the same results.
By the way, is there any place to have all these explained
When use <> for variable or <<>> or{!field} or {{!!filed}} ....

Cheers
Mohammad

Mark S.

unread,
Jul 1, 2018, 12:38:34 PM7/1/18
to TiddlyWiki
I got most of it from tiddlywiki.com and examples in this forum.

TW technology is more like learning a human language than a programming language -- there's a handful of rules and then a whole lot of exceptions.

It would be great to write up an all-up tutorial, but like attacking a hydra, where do you begin?

-- Mark

Dave

unread,
Jul 1, 2018, 1:48:41 PM7/1/18
to TiddlyWiki
I figured out this list of things to remember about TW variables for use in macros:


variable conventions


in a macro

  • $someword$ macro variable provided by parameter of the remote macro call
  • <<someword>>, from: <$set name="someword" value="some value"><– variable set inside the macro
  • $(currentTiddler)$ higher order (global?) variable you can use inside a macro
  • <<currentTiddler>> lower order macro - gives the name of current tiddler, but doesn't go past a single nesting level (as opposed to the example above)
hopefully those are accurate.  I'll have to add the macrocall usage to this now :)

I've just recently figured out that you can set macro definitions for use later in the same tiddler (olmost as a lengthy variable), but not used elsewhere because you don't tag it with $:/tags/macro

Mohammad

unread,
Jul 1, 2018, 1:57:06 PM7/1/18
to TiddlyWiki
Thanks David!

I hope we could have your contribution to TW and its documentation.

Cheers
Mohammad
Reply all
Reply to author
Forward
0 new messages