getDefinedFunctions: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page GetDefinedFunctions to getDefinedFunctions: Converting page titles to lowercase)
m (Text replacement - "source>" to "syntaxhighlight>")
Line 10: Line 10:
getDefinedFunctions(delim)
getDefinedFunctions(delim)
getDefinedFunctions(delim, showFullLocations)
getDefinedFunctions(delim, showFullLocations)
</source>
</syntaxhighlight>
'''Parameters'''
'''Parameters'''
{{param|delim|The delimiter used to separate the output.  If {{code|""}} is specified, the default plain text output is produced.  If {{code|"json"}} is specified, a JSON array is produced.  Otherwise, a string list is produced separated by the given delimiter.  Defaults to {{code|""}}, producing plain text output.  See below for examples of output format.}}
{{param|delim|The delimiter used to separate the output.  If {{code|""}} is specified, the default plain text output is produced.  If {{code|"json"}} is specified, a JSON array is produced.  Otherwise, a string list is produced separated by the given delimiter.  Defaults to {{code|""}}, producing plain text output.  See below for examples of output format.}}
Line 19: Line 19:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[r: getDefinedFunctions()]
[r: getDefinedFunctions()]
</source>
</syntaxhighlight>
Produces:
Produces:
<pre>
<pre>
Line 30: Line 30:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[r: getDefinedFunctions("json", 1)]
[r: getDefinedFunctions("json", 1)]
</source>
</syntaxhighlight>
Produces:
Produces:
<pre>
<pre>
Line 58: Line 58:
[r: theList = getDefinedFunctions(",")]
[r: theList = getDefinedFunctions(",")]
[r, foreach(udf, theList, "<br />"): udf]
[r, foreach(udf, theList, "<br />"): udf]
</source>
</syntaxhighlight>
Produces:
Produces:
<pre>
<pre>

Revision as of 16:59, 14 March 2023

getDefinedFunctions() Function

Introduced in version 1.7
Returns a list of the user defined functions that have been registered with defineFunction(). Uses the corresponding macro's tooltip, if any, as a function description.

Usage

<source lang="mtmacro" line> getDefinedFunctions() getDefinedFunctions(delim) getDefinedFunctions(delim, showFullLocations) </syntaxhighlight> Parameters

  • delim - The delimiter used to separate the output. If "" is specified, the default plain text output is produced. If "json" is specified, a JSON array is produced. Otherwise, a string list is produced separated by the given delimiter. Defaults to "", producing plain text output. See below for examples of output format.
  • showFullLocations - Whether fully-qualified macro locations should be included in the output. Defaults to false.

Examples

For Plain Text output:

<source lang="mtmacro" line> [r: getDefinedFunctions()] </syntaxhighlight> Produces:

  a5e.debug - Lists all the available properties and their values.  Useful for debugging. 
  a5e.jget 
  a5e.output 
  a5e.rollDice - Rolls some dice.

For JSON output: <source lang="mtmacro" line> [r: getDefinedFunctions("json", 1)] </syntaxhighlight> Produces:

[
    {
    "name": "a5e.debug",
    "source": "debug@Lib:Addon5e",
    "description": "Lists all the available properties and their values.  Useful for debugging."
  },
    {
    "name": "a5e.jget",
    "source": "jget@Lib:Addon5e"
  },
    {
    "name": "a5e.output",
    "source": "output@Lib:Addon5e"
  },
    {
    "name": "a5e.rollDice",
    "source": "rollDice@Lib:Addon5e",
    "description": "Rolls some dice."
  }
]

For string list output: <source lang="mtmacro" line> [r: theList = getDefinedFunctions(",")] [r, foreach(udf, theList, "
"): udf] </syntaxhighlight> Produces:

a5e.debug,Lists all the available properties and their values. Useful for debugging.,a5e.jget,,a5e.output,,a5e.rollDice,Rolls some dice.
a5e.debug
Lists all the available properties and their values. Useful for debugging. 
a5e.jget

a5e.output

a5e.rollDice
Rolls some dice.

See Also