created: 20230726145210484 modified: 20230726145757234 tags: [[Variable Usage]] title: Behaviour of invoked variables depends on how the variable was declared type: text/vnd.tiddlywiki \define m1(a1) $a1$ - <<__a1__>> - <> \procedure p1(a1) $a1$ - <<__a1__>> - <> \function f1(a1) "$a1$" "-" [<__a1__>] ="-" [] :and[join[ ]] Invoked in normal wikitext context: `<$transclude $variable=macro/>` or `<>` {{Behaviour of variables invoked via normal wikitext}} Invoked via widget attribute: `
>/>` {{Behaviour of variables invoked via widget attributes}} Invoked via filter operator parameter: `[]` {{Behaviour of variables invoked via filter operator parameter}} Invoked via function call in a filter expression: `[function[macro]]` {{Behaviour of variables invoked via filter expression function call}} !! Examples Below is an example macro, procedure and function definition. All three forms of parameter substitution `$a1$`, `<<__a1__>>`, and `<>` are included in each definition. The output helps illustrate when each form of substitution will or will not have affect. ``` \define m1(a1) $a1$ - <<__a1__>> - <> \procedure p1(a1) $a1$ - <<__a1__>> - <> \function f1(a1) $a1$ "-" [<__a1__>] ="-" [] :and[join[ ]] ``` | !Variable transclusion|!output | | `<>`|<>| | `<>`|<>| | `<>`|<>| | !Widget attribute|!output | | `<$text text=<>/>`|<$text text=<>/>| | `<$text text=<>/>`|<$text text=<>/>| | `<$text text=<>/>`|<$text text=<>/>| | !Filter operator parameter|!output | | `[]`|<$text text={{{[]}}}/>| | `[]`|<$text text={{{[]}}}/>| | `[]`|<$text text={{{[]}}}/>| | !Function call in filter expression|!output | | `[function[m1],[foo]]`|<$text text={{{[function[m1],[foo]]}}}/>| | `[function[p1],[foo]]`|<$text text={{{[function[p1],[foo]]}}}/>| | `[function[f1],[foo]]`|<$text text={{{[function[f1],[foo]]}}}/>|