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

Standard I/O Interface for script

There are 4 built-in functions available in script:
    function __stdin__() {}           // read a byte from Standard Input
    function __stdout__(obj) {}       // write an object to Standard Output
    function __stdinln__() {}         // read a string line from Standard Input
    function __stdoutln__(line) {}    // write a string line to Standard Output

The console object wraps these functions: = function() { return __stdin__(); };
    console.readline = function() { return __stdinln__(); };

    console.write = function(t) { __stdout__(t); };
    console.log = function(t) { __stdoutln__(t); };

Standard I/O Interface at .NET-side

There are two interfaces used in Standard I/O Interface in .NET:
    interface IStandardInputProvider;
    interface IStandardOutputListener;

ReoScript forward the data between script and .NET worlds, once the data is transformed from script, the implementation of the interfaces above will be invoked. To provide your own standard input or output listener, you would have to make your class implementing the interface and register them into ScriptRunningMachine.

Only one IStandardInputProvider can be set to ScriptRunningMachine:
    srm.StandardInputProvider = new MyInputProvider();

One or more IStandardOutputListener can be registered into ScriptRunningMachine:
    srm.AddStandardOutputListener(new MyOutputListener());

Last edited Jul 11, 2013 at 2:05 AM by unvell, version 1