js.evalURI: Difference between revisions
Jump to navigation
Jump to search
m (Conversion script moved page Js.evalURI to js.evalURI: Converting page titles to lowercase) |
No edit summary |
||
Line 9: | Line 9: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
js.eval(namespace, URI, arg1, arg2...) | js.eval(namespace, URI, arg1, arg2...) | ||
</ | </syntaxhighlight> | ||
'''Parameters''' | '''Parameters''' | ||
Line 24: | Line 24: | ||
|example= | |example= | ||
Using {{code|js.evalURI}} on an {{code|expression}}. | Using {{code|js.evalURI}} on an {{code|expression}}. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: js.evalURI("demo", "lib://myToken/macro/myMacro", 5)] | [r: js.evalURI("demo", "lib://myToken/macro/myMacro", 5)] | ||
</ | </syntaxhighlight> | ||
Latest revision as of 18:43, 15 March 2023
This article describes a feature or macro function that is experimental and may be subject to change.
js.evalURI() Function
• Introduced in version 1.10.0
Looks up a resource by identifier and evaluates it as a javascript expression. Supports ECMA 2021 standard. For security, access to native types and external resources are limited. Similarly, all arrays passed in to the javascript environment are shallow copied, so changes to the array do not directly change MapTool's state.
Like js.evalNS(), js.evalURI() does not wrap the fragment in an anonymous function. The statement in tail position (usually the last statement) is the return value for js.evalURI().
Usage
js.eval(namespace, URI, arg1, arg2...)
Parameters
namespace
- The namespace to run the fragment in. It will be created if it does not yet exist.URI
- A URI identifying a valid Javascript fragment.arg1, arg2...
- Any. Will be converted to the equivalent javascript type as needed. Arguments are accessible via theargs
variable.return
- Any primitive type; Complex types are converted to (JSON) strings.
Example
Using
js.evalURI
on an expression
.
[r: js.evalURI("demo", "lib://myToken/macro/myMacro", 5)]