Execute: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
No edit summary
(Undo revision 10468 by Ghenne (talk))
Tag: Undo
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) ==


<tabber>
<pre>
JavaScript=
<syntaxhighlight lang="JavaScript">
Rem Execute execute a string as a SUB
Dim x
x = 5
Execute("PRINT x * 10")
Execute("x = x * 10")
Print x</syntaxhighlight>
|-|
BASIC=
<syntaxhighlight lang="vb.net">
Rem Execute execute a string as a SUB
Rem Execute execute a string as a SUB
Dim x
Dim x
Line 27: Line 16:
Execute("x = x * 10")
Execute("x = x * 10")
Print x
Print x
</syntaxhighlight>
</pre>
</tabber>
 
== Example (JavaScript) ==
<pre>
// Eval execute a string as a SUB
 
var x;
x = 5;
eval("NSB.PRINT(x * 10)");
eval("x = x * 10");
NSB.Print(x);
</pre>


== Output ==
== Output ==

Revision as of 17:47, 22 July 2019

Execute(string)

Description

Execute executes an expression or file as if it were code substituted in the program. The required parameter, string, can be either a string expression or the name of a file containing statements that is executed. If multiple statements are to be executed, separate them with a carriage return (vbCRLF). The code can access and modify all variables in the current running program.

The code in the string is evaluated as JavaScript code. See the TechNote 04, "The role of JavaScript, HTML5 and WebKit".

Example (Basic)

Rem Execute execute a string as a SUB
Dim x
x = 5
Execute("PRINT x * 10")
Execute("x = x * 10")
Print x

Example (JavaScript)

// Eval execute a string as a SUB

var x;
x = 5;
eval("NSB.PRINT(x * 10)");
eval("x = x * 10");
NSB.Print(x);

Output

50
50

Related Items

Eval