TT,
This would be worth a simple summary, to guide users. Since I am not so
sure about your question, I suspect you just had a "mind block".
In your case
<<dostuff "hammer">> will change $thingie$ to be "hammer"
The following is a little verbose because it forms part of a future blog
post
Basically
- if you want to use parameters in a macro they need to be named in the
braces macroname(p1 p3) the access them with $p1$ $p2$
- You can set a *default value for parameters* with
(p1:"defaultvalue",p2)
- When calling the macro the `<<macroname>>` is a little limited, only
literal strings can be used ` <<macroname "value1" "Value2">>`
- Here we are relying on the order of the parameters
- If you want to pass parameters out of order you need to name them, for
example we may want to use the default for p1 and pass only value2
- We use `<<macroname p2:"value2">>` uses the same format as inside
the definition braces ().
- The only way to pass variables and field values to a macro is the
macrocall widget
- `<$macrocall $name="macroname" p1={{!!fieldname)) p2=<<variable>>
p3=<<wikifiedmacro>>/>`
- However variables in the calling wikitext can be accessed in macros
with $(varname)$ without being added to the parameters
- Whenever something is wrapped in $ signs the value is replaced before
the wikitext/macro is evaluated., ro $values$ or $(varname)$ may need to be
quotes etc..
- `<$tiddler tiddler="[[($currentTiddler$)]]">...` (only in macro
definitions)
- There may be cases where you want to use one of the parameters as if
it were a variable
- `<$tiddler tiddler=<<__p2__>> >...`
Other ways to set *default value for parameters*
\define macroname(p1 p2)
<$set name=p1 value="$p1$"emptyValue="defaultValue">
Use <<p1>> not $p1$
</$set>
\end
See how this converts the parameter to a variable?
The default value can be other references or macros as well.
You can even set the `p1` variable multiple times
<$set name=p1 value="$p1$"emptyValue="$(varname)$">
<$set name=p1 value=<<p1>>"emptyValue="defaultValue">
Use <<p1>> not $p1$
</$set></$set>
In this case if the no parameter is provided, and the first emptyValue
"$(varname)$"
is itself empty
Then the defaultvalue will be set
Regards
TW Tones
On Friday, June 26, 2020 at 5:46:46 AM UTC+10, TiddlyTweeter wrote:
>
> I try to be brief ...
>
> \define thing(thingie:"wotnot")
>
> User enters ...
>
> <<thing "hammer">>
>
> I have a second macro ...
>
> \define dostuff(thingie:"wotnot")
>
> How do I get "dostuff" to know the parameter *value* is now "*hammer*",
> not "wotnot"?
>
> This is probably awfully unclear!
>
> Trying to grasp basics.
> TT
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/8e92f3fe-ef52-4e68-b909-60359b083c06o%40googlegroups.com.