defineFunction: Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) m (Corrected misuse of Clarify tag, replace it with a stub tag.) |
Verisimilar (talk | contribs) (Added note about an important nuance of newScope and arg()) |
||
Line 21: | Line 21: | ||
{{param|macro|The name and location of the macro that is called when the user defined function is used.}} | {{param|macro|The name and location of the macro that is called when the user defined function is used.}} | ||
{{param|ignoreOutput|If the defined function should ignore all output and only return the value of {{code|macro.return}}, defaults to {{false}}.}} | {{param|ignoreOutput|If the defined function should ignore all output and only return the value of {{code|macro.return}}, defaults to {{false}}.}} | ||
{{param|newScope|If the defined function should create a new variable scope when executed, defaults to {{true}}. A new variable scope means that the defined function can only read the variables of the macro that called it; if you do not create a new scope the defined function can read, update, and create variables in its parent's variable scope.}} | {{param|newScope|If the defined function should create a new variable scope when executed, defaults to {{true}}. A new variable scope means that the defined function can only read the variables of the macro that called it; if you do not create a new scope the defined function can read, update, and create variables in its parent's variable scope. Updating variables in the parent's scope includes over-writing any parameters that a parent might have stored within {{func|arg}}, if a user-defined function that does not create a new scope is called within another user-defined function.}} | ||
|example= | |example= | ||
Line 31: | Line 31: | ||
|also= | |also= | ||
{{func|oldFunction}} | {{func|oldFunction}}, | ||
{{func|arg}}, | |||
{{func|argCount}} | |||
|changes= | |changes= |
Revision as of 20:44, 27 May 2009
This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.
This article needs: Could use examples of the ignoreOutput and newScope parameters.
defineFunction() Function
Note: This function can only be used in a Trusted Macro
• Introduced in version 1.3b51
Defines a user function that can be used anywhere that core functions can be used. A user defined function is a link to another macro.
Usage
defineFunction(function, macro)
defineFunction(function, macro, ignoreOutput)
defineFunction(function, macro, ignoreOutput, newScope)
Parameters
function
- The name of the user defined function to be defined.macro
- The name and location of the macro that is called when the user defined function is used.ignoreOutput
- If the defined function should ignore all output and only return the value ofmacro.return
, defaults tofalse
(0
).newScope
- If the defined function should create a new variable scope when executed, defaults totrue
(1
). A new variable scope means that the defined function can only read the variables of the macro that called it; if you do not create a new scope the defined function can read, update, and create variables in its parent's variable scope. Updating variables in the parent's scope includes over-writing any parameters that a parent might have stored within arg(), if a user-defined function that does not create a new scope is called within another user-defined function.
Example
[h: defineFunction("character.heal", "heal@Lib:Character")]
character.heal()
which calls heal@Lib:Character
when evoked.See Also
Version Changes
- 1.3b56 - Added
ignoreOutput
andnewScope
parameter options.