some simple examples....
Code:
;this creates an array containing 10 variables of both numbers and strings.
$array = 1,2,3,4,5,"a","b","c","d","e"
;or...use the split command to split a string on a given delimiter, in this case using a single space.
$array = split("1 2 3 4 5 a b c d e"," ")
for each $item in $array
? $item
next
use the DIM or GLOBAL command to declair a blank/empty array.
Code:
;this creates a 10 variable array the array points are 0 to 9
dim $array[9]
$array[0] = 1
$array[1] = 2
$array[2] = 3
$array[3] = 4
$array[4] = 5
$array[5] = "a"
$array[6] = "b"
$array[7] = "c"
$array[8] = "d"
$array[9] = "e"
use the ubound() command to return the uper limit of an array...
Code:
$array = 1,2,3,4,5,"a","b","c","d","e"
$uperlimit = ubound($array)
for $i = 0 to $uperlimit
? $array[$i]
next
use redim to adjust the size of the array, you can preserve the contents as well.
Code:
$array = 1,2,3,4,5,"a","b","c","d","e"
;increase the sice of the array by 1 and asign the last point a value of Z
redim preserve $array[ubound($array)+1]
$array[ubound($array)] = "z"
Fancy nested arrays.....
to use something like Richard's excell analogy, you can stuff an array into an array...
a simple example for a 2 dimension 4x4 array
Code:
0 1 2 3
0 f g h j
1 k l q w
2 e r t y
3 u i o p
using the above example, 02 = "h", 21 = "r"... so on and so forth....
now some code...
Code:
;first DIM the array...
DIM $array[3]
;this will expand the array from a single dimension To into a 2 dimension 4x4 array
For $i = 0 To UBound($array)
$array[$i] = $array
Next
;lets add our data...
$array[0][0] = f
$array[0][1] = g
$array[0][2] = h
$array[0][3] = j
$array[1][0] = k
$array[1][1] = l
$array[1][2] = q
$array[1][3] = w
$array[2][0] = e
$array[2][1] = r
$array[2][2] = t
$array[2][3] = y
$array[3][0] = u
$array[3][1] = i
$array[3][2] = o
$array[3][3] = p
;now print out some of the array cells..
? $array[0][2]
? $array[2][1]
? $array[3][3]
Bryce