Data Sheet

dScript
dScript User Manual v2.15
Variable arrays
A variable array is like a row of variables. To declare an variable array place the size of the
array in square brackets immediately after the variable name.
var TemperatureLog[24]
This declares a row of 24 individual variables (or elements) which can be accessed by using an
index number. The first element is at position 0 and the last element is at position 23 (not 24).
To read or write an array element, specify the element number in the square brackets.
x = TemperatureLog[2]
TemperatureLog[2] = 19
The array index is checked at runtime and any attempt to write to an element outside the
bounds of the array is ignored and attempts to read an element outside the bounds of the
array will return 0.
The size of an array is limited only by the available memory.
Arrays may have multiple dimensions. To declare a two dimensional array place the sizes of the
dimensions, separated by a comma, in square brackets immediately after the variable name.
var myGrid[10,10]
This declares a two dimensional array with 10 elements (numbered 0-9) on each side of the
grid. 100 elements in total. When reading or writing, both dimensions must be specified.
x = myGrid[3,7]
myGrid[3,7] = 123
Arrays may have up to 4 dimensions.
var my3Dgrid[10,10,10]
var my4Dgrid[10,10,10,10]
Arrays may also be used with int8 and int16 variable types.
int8 dataLog[10000]
int16 HourlyTemps[24]
Copyright © 2016, Devantech Ltd.
All rights reserved.
www.robot-electronics.co.uk
12