Arrays |
Top Previous Next |
Creating arrays
PasScript allows to create single-dimensional arrays as well as multi-dimensional, allows to specify both: low bounds and high bounds of the array. The script program should use array constructor syntax to create array. For example: a := array[0..7, 1..3]; // Multi-dimensional array.
The low bound of the array is optional and can be omit. If the code omit low bound it set to zero by default:
a := array[5]; // Same as [0..5] a := array[7, 2]; // Same as [0..7, 0..2]
PasScript also supports creation of the arrays with elements of type other than varVariant. For example, it is possible to create an array with elements of varByte for more efficient data storage:
a := array[100] of Byte;
Following table specifies the list of type names that can be used in array constructor:
If the type name is omit, the array will be created with varVariant element type.
Using arrays
The script program should use square bracket syntax to access array elements, just like in Delphi:
a := array[0..10];
The Length intrinsic function can be used to determine the length of the array. If the array is a multi-dimensional array, the dimension number can be specified as a second argument in a Length function call. The dimension numbers starts from 1. Here some examples:
a := array[0..10]
The Low and High intrinsic functions can be used to determine the low and hight bounds of the array. Just like with Length function, the dimension number can be specified as a second argument:
a := array[0..10]; |