This project has moved. For the latest updates, please go here.

Run JavaScript using ReoScript engine

Download ReoScript binary library or build source code. The following two DLLs must be added into target project.

And import this namespace:
    using Unvell.ReoScript;

There is a main class named ScriptRunningMachine available in ReoScript, you need use it to load/run script.
    ScriptRunningMachine srm = new ScriptRunningMachine();

Now there is a script runing machine and default context was be created. (Learn more about ScriptRunningMachine)
    srm.Run("alert('hello world!');");

A message box with text 'hello world' will be display.

Difference between JavaScript and ReoScript

There is a brief of difference between ReoScript and JavaScript:

1. ReoScript requests more stricter syntax check. Except block (non-anonymous function, if, for, switch and etc.), all the statements in ReoScript should end with a semicolon.
        function count() { return 10 }              // error
        function count() { return 10; }             // ok

        var a = function() { return 10; }           // error
        var a = function() { return 10; };          // ok

See about Language Specification.

2. GlobalObject named window in JavaScript but named script in ReoScript.
        window.hello = function() { };              // JavaScript
        script.hello = function() { };              // ReoScript

See about GlobalObject.

3. Iteration working over on Array will return element self.
        var arr = [1, 5, 'ok', false];
        for(e in arr) console.log(e);

The difference is JavaScript returns index but ReoScript returns element itself as below:
        JavaScript:             ReoScript:
        0                       1
        1                       5
        2                       ok
        3                       false

See about Enumerator.

5. setTimeout and setInterval supported to pass arguments.

It is possible to pass arguments when calling a function by setTimeout or setInterval, for example:
        function run(obj) {
            console.log('Object is ' +;

        setTimeout(run, 1000, {name: 'obj1'});

See about Enhanced Async-Calling.

4. Argument list of a function is called `arguments` in JavaScript but called `args` in ReoScript.
        JavaScript:                                 ReoScript:

        function hello() {                          function hello() {
            console.log(arguments.length);              console.log(__args__.length);
        }                                           }

5. Regular Expressions currently is not supported. However, you can make an extension such as extended native function to support .Net Regular Expressions for script. (See How to extend function for script in .NET program)

6. with keyword is not supported in ReoScript.

7. ReoScript provides several own features, see Language Feature.

Merge script files

In HTML and JavaScript we could use '<script>' tag to import another script file into current page. Once a script file was be imported, all variables and functions defined in that file will be available for current page. It is also possible to implement same effect in ReoScript by using import keyword.

Script File:
    var MAX_PATH = 256;                           // global variable for all script files

    function get_extension(filepath) {
       var index = filepath.lastIndexOf('.');
       return filePath.substr(index + 1);

Script File:
    import "";

    var ext = get_extension('sample.txt');
    console.log('extension is ' + ext);

The result is:
    extension is txt

Run ReoScript in Windows Console

You may also run a file that contains whole ReoScript in Windows Console by ReoScript Runner. It was available since ReoScript 1.2. (See Console Runner)

Last edited Jul 11, 2013 at 3:16 AM by unvell, version 9