mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-07 18:39:57 +00:00
36 lines
1.2 KiB
Plaintext
36 lines
1.2 KiB
Plaintext
|
created: 20221007132845007
|
||
|
modified: 20221007133003128
|
||
|
tags: Pragmas
|
||
|
title: Pragma: \procedure
|
||
|
type: text/vnd.tiddlywiki
|
||
|
|
||
|
The ''\procedure'' [[pragma|Pragmas]] is used to [[define procedures|Procedure Definitions]]. It is a shortcut syntax for the SetVariableWidget.
|
||
|
|
||
|
The usual form allows procedures to span multiple lines:
|
||
|
|
||
|
```
|
||
|
\procedure <procedure-name>(<param-name>[:<param-default-value>],<param-name>[:<param-default-value>]...)
|
||
|
<multiple-line-definition-text>
|
||
|
\end
|
||
|
```
|
||
|
|
||
|
There is also a single line form for shorter procedures:
|
||
|
|
||
|
```
|
||
|
\define <procedure-name>(<param-name>[:<param-default-value>],<param-name>[:<param-default-value>]...) <single-line-definition-text>
|
||
|
```
|
||
|
|
||
|
The first line of the definition specifies the procedure name and any parameters. Each parameter has a name and, optionally, a default value that is used if no value is supplied on a particular call to the macro. The lines that follow contain the text of the procedure text (i.e. the snippet represented by the procedure name), until `\end` appears on a line by itself:
|
||
|
|
||
|
For example:
|
||
|
|
||
|
```
|
||
|
|
||
|
```
|
||
|
|
||
|
Alternatively, the entire definition can be presented on a single line without an `\end` marker:
|
||
|
|
||
|
```
|
||
|
\define sayhi(name:"Bugs Bunny") Hi, I'm $name$.
|
||
|
```
|