Moscrif API Docs for: 2012q3
Show:

Global Class

Library: core

Following functions and variables that "live" in global namespace so they accessible in script without any namespace designator.

Example:

// execute a surce code
var r = eval("348.0 / 23.7");
console << r << "\n";

Item Index

Attributes

Events

Methods

crackUrl

(
  • url
)
Object

Parses the url string.

Parameters:

  • url String

    Url string too parse.

Returns:

Object: Returns an object having following fields:
  1. port - integer, tcp/ip port number;
  2. protocol - string, protocol like "http", "file", etc.;
  3. hostname - string, host name;
  4. anchor - string, anchor;
  5. username - string;
  6. password - string;
  7. params - string, parameters of http GET request
  8. dir - string, directory
  9. name - string, filename without extension
  10. ext - string, extension
  11. name_ext - string, filename with extension.

Example:

crackUrl("http://public::8443/svn").show();
// displays
Class Object: [object Class]
    Properties:
        params: ""
        dir: ""
        ext: ""
        port: 8443
        name_ext: "/svn"
        protocol: "http"
        name: "/svn"
        hostname: "mothiva.com"
        anchor: ""
        username: "public"
        password: "mothiva.com:8443"

fetch

(
  • file
)
Object

Restores value previously written into the file (filename) or stream by function store.

Parameters:

  • file String | Stream

    Either string - file name or stream object for source file.

Returns:

Object: Restored value or null if operation failed.

gc

()

Invokes garbage collector.

hash

(
  • value
)
Integer

Hash value of its argument.

Parameters:

  • value Object

    Value to hash.

Returns:

Integer: Hashed value of its argument.

membersOf

(
  • obj
)
Object

Creates map (simple object) that has the same set of properties as the obj. Main purpose of membersOf is to be used in for(var (k,v) in membersOf(obj)) alike enumerations to scan properties of entities that have different semantic of enumeration than in instances of Object.

Parameters:

Returns:

Object: Map (simple object) that has the same set of properties as the obj.

parseData

(
  • input
  • [env]
)
Object

Evaluates (interprets) input and returns its value. If input is a string then function tries to interpret it as if it contains script source code. If input is a stream object then it compiles and executes source code from it.

Parameters:

  • input String | Stream

    String or stream object, containing source code to run.

  • [env] Object optional

    Is an environment object - if provided then script execution takes place in the namespace of that object..

Returns:

Object: Value of the input

Example:

//Example: after execution of the following:
var obj = eval("({ one:1, two:2 })");
variable obj now contains object having two fields: one and two.
var res = eval("one + two;", obj);
//After execution of two lines above variable res will contain integer 3.

parseData

(
  • input
)
Object

JSON++ data parser.Evaluates (interprets) data literal at the input and returns its value. Input shall contain valid data literal expression otherwise parsing exception will be thrown. Main difference from the eval function is that parseValue will not parse and execute any function declarations or functions so it is safe to use this function when data is coming from unknown sources e.g. in AJAX like of interactions.

Parameters:

  • input String | Stream

    String or stream object, containing source code to parse

Returns:

Object: Value of the input

Example:

//Example 1: after execution of the following:
var obj = parseValue("{ one:1, two:2 }");
//variable obj will contain object having two fields: one and two.

//Example 2: after execution of the following:
var v = parseValuel("3.1415926");

//variable v will contain float number 3.1415926 - parsed value of the string.

rand

(
  • maxNumber
)
Integer

Generate a random number between 0 and maxNumber-1.

Parameters:

  • maxNumber Integer

    Upper limit of generated numbers

Returns:

Integer: Random number ranged 0..maxNumber-1

Example:

var limit = rand(100); // 0..99
console << limit << "\n";

store

(
  • file
  • value
)
Boolean

Stores the value into file filename or stream in binary form.

Parameters:

  • file String | Stream

    String - file name or Stream object for output file.

  • value Object

    Value to store.

Returns:

Boolean: true if data was stored successfully

symbol

(
  • string
)
Symbol

Function returns symbol of the string. Internally symbol is 32bit value so symbol space is limited - it makes no sense to "symbolize" arbitrary strings.

Parameters:

Returns:

Symbol:

Attributes

console

Stream

Standard input/output stream. Intended to use for debugging purposes.

Example:

console << "Hello\n";
console << "Hello" <<  "\n";
console << "\tHello" <<  "\n";
console << 1234 << " " << {x:10} << "\n";
console.printf("Hello");
console.printf("Integer %d", 123);

Events

onError

Handle application errors.

Event Payload: