eval: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function Eval== Evaluates and "executes" the expression in a string and returns the result. The string contains the same type of expression that is between '''{}''' or '''[r: ]''' ===Us...)
 
No edit summary
Line 1: Line 1:
==Function Eval==
{{MacroFunction
Evaluates and "executes" the expression in a string and returns the result. The string contains the same type of expression that is between '''{}''' or '''[r: ]'''
|name=eval
|description=Evaluates and "executes" the expression in a string and returns the result. The string contains the same type of expression that is between '''{}''' or '''[r: ]'''


===Usage===
|usage=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: result = eval(expr)]
[h: result = eval(expr)]
</source>
</source>


 
|examples=
===Examples===
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[r: eval("1+1")]
[r: eval("1+1")]
Line 32: Line 32:
Returns
Returns
     1
     1
}}
[[Category:Miscellaneous Function]]

Revision as of 01:53, 7 March 2009

eval() Function

Evaluates and "executes" the expression in a string and returns the result. The string contains the same type of expression that is between {} or [r: ]

Usage

[h: result = eval(expr)]

Examples

[r: eval("1+1")]

Returns

   2
[r: eval("3d1")]

Returns

   3
[r: eval("blah = 2")]

Returns

   2
[h: blah = 2][r: eval("blah/2")]

Returns

1