evalMacro: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
==Function evalMacro, execMacro==
{{MacroFunction
{{TrustedOnlyFunction}}
|name=evalMacro {{!}} execMacro
 
|trusted=true
 
|version=1.3b49
'''Introduced in MapTool 1.3b49'''
|description=Evaluates and "executes" the macro in a string and returns the result. The string contains the same type of macro commands that you would put in a token macro with the exception that it can not contain slash commands.
 
 
Evaluates and "executes" the macro in a string and returns the result. The string contains the same type of macro commands that you would put in a token macro with the exception that it can not contain slash commands.


If you are performing rolls in the macro that create tool tips or use [e: ] then you will have to use either { } or [r: ] to display the output otherwise you will get incorrect formatting. The evalMacro() function executes the macro in the same variable scope (i.e. the executed macro can read and alter variables from the current macro), where as execMacro() crates a new variable scope (i.e. the executed macro can neither read nor alter varaibles from the current macro).
If you are performing rolls in the macro that create tool tips or use [e: ] then you will have to use either { } or [r: ] to display the output otherwise you will get incorrect formatting. The evalMacro() function executes the macro in the same variable scope (i.e. the executed macro can read and alter variables from the current macro), where as execMacro() crates a new variable scope (i.e. the executed macro can neither read nor alter varaibles from the current macro).


===Usage===
|usage=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: result = evalMacro(macroString)]
[h: result = evalMacro(macroString)]
Line 16: Line 13:
</source>
</source>


 
|examples=
===Examples===
To set the notes of a token to the output generated by a macro.
To set the notes of a token to the output generated by a macro.
<source lang="mtmacro" line>
<source lang="mtmacro" line>
Line 28: Line 24:
[h: setNotes(execMacro('[r,macro("CreateNotes@Lib:Notes"): ""]'))
[h: setNotes(execMacro('[r,macro("CreateNotes@Lib:Notes"): ""]'))
</source>
</source>
}}
[[Category:Miscellaneous Function]]

Revision as of 02:01, 7 March 2009

evalMacro | execMacro() Function

 Note: This function can only be used in a Trusted Macro

Introduced in version 1.3b49
Evaluates and "executes" the macro in a string and returns the result. The string contains the same type of macro commands that you would put in a token macro with the exception that it can not contain slash commands. If you are performing rolls in the macro that create tool tips or use [e: ] then you will have to use either { } or [r: ] to display the output otherwise you will get incorrect formatting. The evalMacro() function executes the macro in the same variable scope (i.e. the executed macro can read and alter variables from the current macro), where as execMacro() crates a new variable scope (i.e. the executed macro can neither read nor alter varaibles from the current macro).

Usage

[h: result = evalMacro(macroString)]
[h: result = execMacro(macroString)]

Examples

To set the notes of a token to the output generated by a macro.
[h: setNotes(evalMacro('[r,macro("CreateNotes@Lib:Notes"): ""]'))

or

[h: setNotes(execMacro('[r,macro("CreateNotes@Lib:Notes"): ""]'))