-
Notifications
You must be signed in to change notification settings - Fork 35
Standard IO Interface
Jing Lu edited this page Jun 19, 2013
·
5 revisions
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:
console.read = function() { return __stdin__(); };
console.readline = function() { return __stdinln__(); };
console.write = function(t) { __stdout__(t); };
console.log = function(t) { __stdoutln__(t); };
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());