Locago

IScript Reference Documentation

Version: 1.0 beta, Date: 2008-04-03

The script language IScript is a subset of the JavaScript (ECMAScript) language. With IScript you basically can:

  • Access objects and properties likedoc.fields.myField.value
  • Set properties this.value="jp"
  • Call methods like doc.back()
  • Create built in simple objects such as strings and numbers, example "hello", 3.14
  • Create built in complex objects often called JSON objects, example {1, "2", [3,4]}

One interesting property of IScript is that a method takes at most one argument. This does not limit the language since a complex object that contains several properties can be passed as argument.

Example:
app.send({number:"317790960", message:"hello"})
Types are converted automatically to the required type as in JavaScript. I.e. you can pass a string with a number as well as a number if the method takes a number.

Informal definition of syntax

A script consists of e sequence of expressions separated by semicolon.

Example:
this.value=3; app.showMap()
Extra semicolons between or after expressions are ignored.

An expression is either an assignment or a method call. Getting a property is also considered being a method call without any argument.

A few variables exist in the environment that can be used for accessing their properties or calling their methods. Typically this and doc are available and others depending on the context executing in.

Subobjects are accessed with the dot-notation.

Example:
this.value=doc.fields.name.value

Method calls are done with the ()-notation passing zero or one parameter inside the parenthesis.

Example:
doc.link("http://idevio.com/")

Notable differences to JSON

Escape characters in a String have no effect. Use double quotes for strings that contain single quotes and vice versa.

The boolean values true and false are not available, use the strings 'true' and 'false'.

No exponent form for decimal numbers is available, i.e. 1.2e3 is NOT a valid number.

Built in types

The next section describes the types that are always available in IScript.

Available Types

Number

A number is an integer or real value on the format:
[-]int[.frac]
Where int is the integer part that is required. The fraction part, frac is optional and should be separated from the integer part with a dot. The minus sign is optional. The following are examples of numbers:
42, 3.14, -273.15

String

A string is a sequence of characters surrounded either with "" or ''. All characters except newline and in the case the string is surrounded with "", ', and if it is surrounded with '', " are allowed. The following are examples of strings:
"hello", "that's it", 'this string may have "quotes"'

Object

An Object (or complex value) is a set of key/value pairs enclosed in curly brackets ({}). The key and value is separated by colon (:) and each key/value pair is separated by comma (,). The values are access with the dot-notation. As an alternative, the get-method can be used. The following is an example of an Object:
{name:"Bart", location:"Springfield", age:12}

get( : string)

ParameterTypeUseDescription
string The key (name) of the value to access. This is an alternative to the dot-notation. It is useful if the key contains characters that are not allowed in a script such as space.
Returns the named value. The following two examples do the same thing:
this.value
this.get("value")

Array

An Array is a sequence of values enclosed in square brackets ([]) where the values are separated by comma (,). The following is an examples of an Array:
["Bart", "Springfield", 12]

get( : int)

ParameterTypeUseDescription
int The index of the value to access.
Returns the value at the specified position. The first value is at index 0.