Function Calling Convention
Overview
Functions are macros which are embedded in the wiki text that when called can alter the text of the wikipage, add meta-data, modify formatting, search, etc. Whitespace before and after the delimiters does not affect the values being passed.
Parameters
Parameters are the values that are passed to functions which dictate their behavior. When multiple parameters are being passed to a function, they must be delimited by a comma (,) symbol.
Parameters come in three varieties:
- Required
- When a function has required parameters, they must be passed, or an error will occur. If a function has required parameters, they will always the first parameters.
- Required parameters cannot come after optional parameters.
- Optional
- If a function has optional parameters, they do not need to be specified in the function call.
- If a function has both optional and required parameters, the optional parameters will always come after the required.
- Optional parameters have default values which are used when the parameter is not passed.
- Infinite
- Infinite parameters are rather special but are used quite frequently in this wiki.
- Infinite parameters allow you to pass many values to a function. For example, if you were to call a function that takes "search terms" as a parameter, you'd likely want to add more than one term. Infinite parameters allow you to do just that.
- Infinite parameters can be either optional or required.
- All parameters that come after an infinite parameter will always be optional.
- All parameters that come after an infinite parameter must be passed by name.
Basic function call with infinite parameter
In this example, you can see that we are calling the TextList() function and passing it several search terms. We are able to pass as many as we like because the first parameter of the TextList() function is an infinite parameter.
Example
##TextList(wiki, help, official )Named optional parameters
Again, in this example, you can see that we are calling the TextList() function and passing it several search terms - but we also want to now pass the top parameter to limit the number of pages the function will return. As discussed previously, if the optional parameter comes after an infinite parameter, then we must pass the optional parameter by name.
Passing an optional parameter by name is as simple as placing a colon before the name of the parameter, followed by an equal sign and then the value we want to pass. See below that the :top=5 parameter is being passed by name:
Example
##TextList(wiki, help, official , :top=5)Additionally if we want to pass the view parameter, we'd add a (,) symbol to denote a new parameter and then specify the colon, parameter name and value just as before: :view=List:
Example
##TextList(wiki, help, official , :top=5, :view=List)Discrete parameters
Some functions take parameters that expect specific values from a discrete set of values to be passed. If you pass an invalid parameter value, an error will occur.
Parameter data types
Parameters are constrained to one of several data types:
- String
- String are text type parameters. Basically, everything goes. When you need to include special characters (such as a comma), you can enclose your string parameter in double quotes. If you also need to include a doublequote in your text, you can escape with a backslash (\). For example "This \"is\" a test".
- Integer
- Non-decimal numeric values between -2,000,000,000 and +2,000,000,000
- Float
- Decimal numeric values between. Both precise and large.
See Also
Function Calling Convention
Scope Function
Instruction Function
Standard Function
Related
- Alert - Alerts bring important information to the attention of the reader.
- AppVersion - Displays the wiki engine version.
- Attachments - Lists the attached files associated with a page.
- Background - Set the background color for a block of content.
- BR - Inserts one or more line-breaks into the wiki body.
- Bullets - Create hierarchical ordered or unordered lists.
- Callout - Prominently display useful information in a fairly understated panel.
- Card - Cards are good for displaying every-day content and can have a title.
- Code - Display formatted, wiki-unprocessed and syntax-hilighted code.
- Collapse - Dynamically show or hide a section of the wiki body.