Variables store numbers. For defining a variable, use a C style declaration, like this:
int name; // uninitialized variable int name = 123; // initialized variable
This declaration creates a variable of type int with the given name. The name can contain up to 30 characters, and must begin with A..Z, a..z, or an underscore _.
Type | Size | Range | Precision |
piInt64 | 8 bytes | -9223372036854775808 to 9223372036854775807 | 1 |
piUInt64 | 8 bytes | 0 to 18446744073709551616 | 1 |
int, piInt32 | 4 bytes | -2147483648 to 2147483647 | 1 |
uint, piUInt32 | 4 bytes | 0 to 4294967296 | 1 |
piInt8 | 1 byte | -128 to 127 | 1 |
piUInt8 | 1 byte | 0 to 256 | 1 |
double | 8 bytes | -1.8·10308 to 1.8·10308 | > 2.2·10-308 |
Integer constants in the program - such as character constants ('A'), integer numeric constants (12345) or hexadecimal constants (0xabcd) are treated as int. Constants containing a decimal point (123.456) are treated as float.
int[] name; // array definitionThe append function can add elements to the end of the array:
int[] my_array; // define a new array
my_array.append(1,2,3); // the array now contains 3 variables with the numbers 1,, 2, 3 my_array.append(4); // add a fourth variable
The elements of an array can be accessed with
array[n] // get or set the n-th element. n must be smaller than the number of elements in the array!
The number of elements in an array can be retrieved with
array.size();
Elements can be removed with
array.remove(1); // remove the first element
Elements can be inserted at a certain place with
array.insert(0, 10); // insert an element before the first element, and give it the value 10
Rather than using append, the initial size of an array can be set with
array.setSize(100); // generate 100 elements, and remove all prior elements
For testing if an array contains any elements, use
array.empty(); // true: array is empty / false: array contains elements
Finally, for removing all elements from an array, use
array.clear(); // remove all elements
► latest version online