Global Class
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
Parses the url string.
Parameters:
-
url
StringUrl string too parse.
Returns:
- port - integer, tcp/ip port number;
- protocol - string, protocol like "http", "file", etc.;
- hostname - string, host name;
- anchor - string, anchor;
- username - string;
- password - string;
- params - string, parameters of http GET request
- dir - string, directory
- name - string, filename without extension
- ext - string, extension
- 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
Restores value previously written into the file (filename) or stream by function store.
Returns:
gc
()
Invokes garbage collector.
hash
value
Hash value of its argument.
Parameters:
-
value
ObjectValue to hash.
Returns:
membersOf
obj
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:
-
obj
Object | FunctionObject to map.
Returns:
parseData
input
[env]
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:
Returns:
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
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.
Returns:
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
Generate a random number between 0 and maxNumber-1.
Parameters:
-
maxNumber
IntegerUpper limit of generated numbers
Returns:
Example:
var limit = rand(100); // 0..99
console << limit << "\n";
store
file
value
Stores the value into file filename or stream in binary form.
Parameters:
Returns:
symbol
string
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:
-
string
String
Returns:
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);