Eval: Difference between revisions
Jump to navigation
Jump to search
C185driver (talk | contribs) m →Output |
Add javascript snippet |
||
Line 7: | Line 7: | ||
The code in the string is evaluated as JavaScript code. See the TechNote 04 “The role of JavaScript, HTML5 and WebKit”. | The code in the string is evaluated as JavaScript code. See the TechNote 04 “The role of JavaScript, HTML5 and WebKit”. | ||
== Example == | == Example (Basic) == | ||
<pre> | <pre> | ||
Line 17: | Line 17: | ||
Eval("x = x * 10") | Eval("x = x * 10") | ||
Print x | Print x | ||
</pre> | |||
== Example (JavaScript) == | |||
<pre> | |||
// Eval Example | |||
/* Eval execute a string as a Function */ | |||
var x; | |||
x = 5; | |||
NSB.Print(eval("x")); | |||
eval("x = x * 10"); | |||
NSB.Print(x); | |||
</pre> | </pre> | ||
Revision as of 16:48, 19 May 2013
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 04 “The role of JavaScript, HTML5 and WebKit”.
Example (Basic)
Rem Eval Example 'Eval execute a string as a Function Dim x x = 5 Print Eval("x") Eval("x = x * 10") Print x
Example (JavaScript)
// Eval Example /* Eval execute a string as a Function */ var x; x = 5; NSB.Print(eval("x")); eval("x = x * 10"); NSB.Print(x);
Output
5 50