eval

Category: Script
Since engine version: 1.0 OC

Description

Executes a string as script.

Syntax

any eval(string script, bool dont_pass_errors);

Parameters

script:
Script to be executed
dont_pass_errors:
If true and the script causes an error, the function returns nil and does not cancel its parent script execution.

Example

var v1, v2, v3, v4, v5;
for(var i = 1; i <= 5; i++) eval( Format("v%d = %d", i, i * i) );
Sets the variables v1 to v5 with the squared values of 1 to 5. (The script snippets "v1 = 1", "v2 = 4" ... "v5 = 25" are created with Format and executed with "eval".)
PeterW, 2002-04