Eval: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
Brendon (talk | contribs)
Created page with "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 strin..."
 
Brendon (talk | contribs)
No edit summary
Line 1: Line 1:
EVAL(''string'')
Eval(''string'')


'''Description'''
== 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.
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”.


'''Example'''
== Example ==


<pre>
<pre>
REM EVAL Example
REM Eval Example
'EVAL execute a string as a FUNCTION
'Eval execute a string as a FUNCTION
DIM x
Dim x
x = 5
x = 5
PRINT EVAL("x")
PRINT Eval("x")
EVAL("x = x * 10")
Eval("x = x * 10")
PRINT x
PRINT x
</pre>
</pre>


'''Output'''
== Output ==


<pre>
<pre>
Line 26: Line 26:
</pre>
</pre>


'''Related Items'''
== Related Items ==


[[execute|EXECUTE]]
[[execute|EXECUTE]]
[[Category:Language Reference]]

Revision as of 21:08, 8 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

Related Items

EXECUTE