Multichannel Systems Roboocyte2 User Manual

Roboocyte2 JavaScript Documentation
Roboocyte2 Version 1.1.5 2011-11-03

Roboocyte2 scripts

Scripts are written in the Roboocyte2 text editor. They are saved in ASCII format and thus can be edited also using a standard text editor (like Notepad). It must NOT be opened with a text processing program like Microsoft Word or Open/Libre Office Writer.

Summary of the Roboocyte2 JavaScript syntax

JavaScript is case sensitive
statements should be terminated with a semicolon (';')
statements can be grouped in code blocks within curly brackets {}
a commented line starts with // (everything after // is not executed)
multiline comments start with /* and end with */
variable names must begin with a letter or an underscore, numbers are allowed within a name,
no other characters, especially no blanks are allowed. Reserved words cannot be used as variable names
numbers are either integers (e.g. 420) or floating point numbers (e.g. 3.1). The decimal symbol must be a dot.
a string is text within double or single quotes („text2“, 'text2')
boolean values are true and false

Brief documentation

Here we describe only the most important JavaScript elements, see Further Reading for more detailed descriptions and references.
For a working example with the Roboocyte2 software see the examples scripts, especially
JavaScript_Example.js

Data types

A value, the data assigned to a variable, may consist of any sort of data. However, JavaScript considers data to fall into several possible types. Depending on the type of data, certain operations may or may not be able to be performed on the values. For example, you cannot arithmetically multiply two string values. Variables can be these types1:
Type Description Example
Integer number integral numbers, negative numbers are prefixed by - 1, -3, 0
floating point number decimal point must be a dot: '.' 3.14,
string text within single or double quotes
„Hello“
1 quoted from: http://www.wdvl.com/Style/JavaScript/Tutorial/variables.html
Undefined
the value of a variable before it gets a value by assignment. Occurs in an array when not all members have been assigned

Arithmetic operators

Mathematical calculations on numbers are made by using the followeing arithmetic operators:
Operator Description Example
+
addition
y = x + 2;
-
subtraction
y = x – 2;
*
multiplication
y = x * 2;
/
division
y = x / 2;
++
increment by 1, usually used in a for loop
i++
--
decrement by 1
i--

String functions

Strings can be manipulated by a number of functions operating on them. The addition operator „+“ has the meaning of concatenation when used on strings:
Function Paramters Description Example
+ operator
- concatenation 'up' + 'date' yields
'update'
length
- number of characters in the string
var s3 = 'update'; s3.length is 6
[index]
- get the character with the given index, starting at 0
s3[2] is 'd'
substring
int: startindex, int: stopindex
returns the substring from startindex to stopindex
s3.substring(1, 3) is 'pd'
split
string: separator splits string in a part for each occurence
of separator, returns an aray of the string parts
var s4 = "a:b:cde:fg:h"; gives an array
indexOf
string: substring returns the index of the first occurence
of the substring, -1 if not found
concat
list of strings concatenates the string with all strings
in the parameter list

Variables and assignment operators

Variables are used to store values. The value can be retrieved later in the script by using the variable name. A new variable should be declared with the keyword var.
A value is assigned to a name by using an assignment operator (=, +=, -=, *=, /=). Usually = is used, e.g.
var x = 50;
or
var minimumResult = -50;
Loading...
+ 3 hidden pages