Eval: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
== Description == | == Description == | ||
Eval returns a value created by executing an expression as if it were a | Eval returns a value created by executing an expression as if it were a Function procedure. The required parameter, ''string'', is a string expression that is executed. If multiple statements are to be executed, separate them with a carriage return (vbCRLF). The temporary, virtual procedure that gets created has all program variables passed in by value, so the variables are unmodifiable by the Eval function. | ||
The code in the string is evaluated as JavaScript code. See the TechNote “Using JavaScript with NS Basic/X Programs”. | The code in the string is evaluated as JavaScript code. See the TechNote “Using JavaScript with NS Basic/X Programs”. | ||
Line 10: | Line 10: | ||
<pre> | <pre> | ||
Rem Eval Example | |||
'Eval execute a string as a | 'Eval execute a string as a Function | ||
Dim x | Dim x | ||
x = 5 | x = 5 | ||
Print Eval("x") | |||
Eval("x = x * 10") | Eval("x = x * 10") | ||
Print x | |||
</pre> | </pre> | ||
Line 28: | Line 28: | ||
== Related Items == | == Related Items == | ||
[[execute| | [[execute|Execute]] | ||
[[Category:Language Reference]] | [[Category:Language Reference]] |
Revision as of 00:45, 24 August 2012
Eval(string)
Description
Eval returns a value created by executing an expression as if it were a Function procedure. The required parameter, string, is a string expression that is executed. If multiple statements are to be executed, separate them with a carriage return (vbCRLF). The temporary, virtual procedure that gets created has all program variables passed in by value, so the variables are unmodifiable by the Eval function.
The code in the string is evaluated as JavaScript code. See the TechNote “Using JavaScript with NS Basic/X Programs”.
Example
Rem Eval Example 'Eval execute a string as a Function Dim x x = 5 Print Eval("x") Eval("x = x * 10") Print x
Output
5 5