interpret

This is likely your main entry point to the interpreter. It will interpret the script code given, with the given global variable object (which will be modified by the script, meaning you can pass it to subsequent calls to interpret to store context), and return the result of the last expression given.

var globals = var.emptyObject; // the global object must be an object of some type
globals.x = 10;
globals.y = 15;
// you can also set global functions through this same style, etc

var result = interpret(`x + y`, globals);
assert(result == 25);
More...
var
interpret
(
string code
,
var variables = null
,
string scriptFilename = null
,
string file = __FILE__
,
size_t line = __LINE__
)

Parameters

code string

the script source code you want to interpret

scriptFilename string

the filename of the script, if you want to provide it. Gives nicer error messages if you provide one.

variables var

The global object of the script context. It will be modified by the user script.

Return Value

Type: var

the result of the last expression evaluated by the script engine

Detailed Description

If you want to just call a script function, interpret the definition of it, then just call it through the globals object you passed to it.
var globals = var.emptyObject;
interpret(`function foo(name) { return "hello, " ~ name ~ "!"; }`, globals);
var result = globals.foo()("world");
assert(result == "hello, world!");

Meta