Following functions and variables "live" in global namespace so they accessible in script without any namespace designator, e.g.
var r = eval( " 348.0 / 23.7 " );
stdout.printf( "%f" , r );
Global variables | |||
stdin | stream, standard input stream. Read-only. |
These streams are created and managed by host application of the script engine |
|
stdout | stream, standard output stream. Write-only. | ||
stderr | stream, standard error stream. Engine reports here about all uncought exceptions. | ||
Global functions | |||
eval |
( input : string|stream [, env :object ] ) : value
Evaluates (interprets) input and returns its value. If input is a string than function interprets it as it is contain script source code. If input is a stream object then it compiles and executes source code from it. Example: after execution of the following:
variable obj will contain object having two fields: one and two. env is an environment object - if provided then script execution takes place in namespace of that object.
After execution of two lines above variable res will contain integer 3. |
These functions available only if host application configured the engine to use them.
|
|
emit |
( input :string|stream, output :stream [, env :object ] ) :value
Evaluates input stream in serverScript mode (see below) and emits result to output stream. Function assumes that executable script at the input text is contained in <% %> brackets. Function returns result of first standalone return statement in the input stream. env is an environment object - see explanation above. env allows to pass parameters to the input script from caller. |
||
load |
( source [, asServerScript] ) :true|false
Loads (compiles and executes) source. Source here either string - file name or stream object. If asServerScript provided and equals to true then source is interpreted as text with imbedded script like PHP or ASP web page source: <html> ... <% =some_script_function(); %>... </html> These two fragments are equivalent:
Script execution takes place in namespace of caller of the function. |
||
loadbc |
( source ) : true | false
Loads compiled bytecodes defined by source. Source here either string - file name or stream object. |
||
compile |
( filename_in, filename_out ) or
( stream_in, stream_out ) : true | false Calls builtin compiler to compile in. Writes output bytecodes into out stream or file. Bytecodes can be loaded (executed) later by loadbc function. |
||
store |
( filename | stream, value ) : true | false
Stores the value into file filename or stream in binary form. Returns true if data was stored successfully. |
||
fetch |
( filename | stream ) : value | null
Restores value previously written into file filename or stream by function store. Returns the value or null if operation failed. |
||
hash |
( value ) : integer Returns hash value of its argument. |
||
rand |
( maxNumber ) : integer Returns a random number between 0 and maxNumber-1. |
||
gc |
( ) : undefined
Invokes garbage collector. |