1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-09 19:39:57 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/pragmas/Pragma_ _function.tid
jeremy@jermolene.com 55e38eb89a Update modification times of doc tiddlers
So that they are at the top of the recent tab
2023-04-19 11:32:34 +01:00

27 lines
1.3 KiB
Plaintext

created: 20221009162634214
modified: 20230419103154329
tags: Pragmas
title: Pragma: \function
type: text/vnd.tiddlywiki
<<.from-version "5.3.0">> The ''\function'' [[pragma|Pragmas]] is used to [[define custom functions|Functions]]. It is a shortcut syntax for the SetVariableWidget.
The usual form allows custom functions to span multiple lines:
```
\function <function-name>(<param-name>[:<param-default-value>],<param-name>[:<param-default-value>]...)
<multiple-line-definition-text>
\end [<function-name>]
```
Note that the `\end` marker can optionally specify the name of the function to which it relates, enabling function definitions to be nested inside procedures, macros or widget definitions.
There is also a single line form for shorter functions:
```
\function <function-name>(<param-name>[:<param-default-value>],<param-name>[:<param-default-value>]...) <single-line-definition-text>
```
The first line of the definition specifies the function 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 function. The lines that follow contain the text of the function (i.e. the snippet represented by the function name), until `\end` appears on a line by itself:
See [[Functions]] for more details.