FUNCTION
Command: #function {name} {operation}
Functions allow you to execute a script within a line of text, and
replace the function call with the line of text generated by the
function.
Be aware that each function should use the #return command at the
end of the function with the result, or set the {result} variable.
To use a function use the @ character before the function name.
The function arguments should be placed between braces behind the
function name with argument separated by semicolons.
Functions can be escaped by adding additional @ signs.
Example: #function test #return 42;#showme @@test{}
The function itself can use the provided arguments which are stored
in %1 to %99, with %0 holding all arguments.
Example: #function {rnd} {#math {result} {1 d (%2 - %1 + 1) + %1 - 1}}
#show A random number between 100 and 200: @rnd{100;200}
Example: #function gettime {#format result %t %H:%M}
#show The current time is @gettime{}
Comment: You can remove a function with the #unfunction command.
Related: format, local, math, replace, script and variable.
|