The first line of the definition specifies the macro name and any parameters. Parameters are named and can optionally have default values that are used if the parameter isn't specified at the time of calling. The body of the macro definition follows, terminated with `\end` on a line by itself.
The text of the macro can reference parameters using the `$name$` syntax. The value of the parameter is substituted at the time the macro is invoked.
!! Variable Substitution
The values of named variables can also be substituted into the text of a macro using the syntax `$(variable)$`. For example:
```
\define mysamplemacro2()
Hi, I'm $(name)$ and I live in $(address)$
\end
\define name() Bugs Bunny
<$set name="address" value="Rabbit Hole Hill">
<<mysamplemacro2>>
</$set>
```
The result is: `Hi, I'm Bugs Bunny and I live in Rabbit Hole Hill`.
!! Single Line macros
Single-line macros can omit the `\end` marker like this:
Macro definitions must be placed at the top of a tiddler. Macros are available to the tiddler that defines them, plus any tiddlers that it transcludes.
Global macros can be defined in any tiddler with the tag [[$:/tags/Macro]]. They are then available within all tiddlers.
Macros can be imported from other tiddlers with the ImportVariablesWidget.
[[JavaScript Macros|http://tiddlywiki.com/dev/index.html#JavaScript%20Macros]] can also be used for more flexibility.
! Using Macros
In their simplest form, macros are used like this: