Confusion with procedure parameter

Hi everyone,

I’m playing with the new concept of procedure in TW 5.3 prerelease, and I must say that so far it feels much easier than traditional macros for an amateur like yours truly.

I probably have some misunderstanding about this point though: apparently there’s something not working when I pass a reference as argument, like this:

\procedure example(n:"1")
<<n>> {{{[<n>multiply[3]]}}}
\end

direct value n: <<example n:4>>

field value n: <<example n:{{!!param}}>>

In the second case the tillder must have a field param with value 4 (or any number)

The first call gives the expected result 12, but the second one gives 0 because the <n> inside the filter appears undefined, even though the value is printed.

Am I missing something? Isn’t this supposed to work?

Thank you!

i think in the second case you want to use the macrocall widget

1 Like

Not that I have any idea because I’ve been avoiding procedures.

I gotta say, though: needing “macrocall” to invoke a “procedure”, that’s pretty confusing.

@Surge is right to recommend using a widget. Inside the variable expansion syntax (<<>>) wikitext is not expanded. While using the macrocall widget would work, my preference is to use the transclude widget. For example

<$transclude $variable=example n={{!!param}}/>

In 5.3, parameterized wikitext can be stored in tiddlers or in variables (\define, \procedure, \widget, \function, $let, $set, $vars). The $transclude widget unifies access to both of these via either <$transclude $variable="somevar"/> or <$transclude $tiddler="sometiddler"/>

Not required, but it will work.

2 Likes

Ok, I see…

I didn’t reach this part yet in my experiments but your clear explanations make me eager to try, it looks quite intuitive indeed :slight_smile:

Thank you all !

Macro call is the long form of calling a macro and allows parameters not allowed in a short form ‘<< >>’ in 5.3.0 your can do something similar using the transclude widget and the $variable parameter.