Action:
Creates one,two or three dimensional KiXtart arrays
Syntax:
Array($dx,[$dy,[$dz]])
Parameters:
$dx : The upper bounds of the first dimension
$dy : Optional - The upper bounds of the second dimension
$dz : Optional - The upper bounds of the third dimension
Returns:
An uninitialized one,two or three dimensional array
Remarks:
Avoid the tempation to rename this function MakeArray(). This function name
is already reserved by KiXtart for future use !
Dependencies:
KiXtart 4.0 (Final)
Example(s):
$array = Array(9) ; create a single array with 10 elements (0-9)
$array = Array(9,9) ; create a two dimensional array with 100 elements (0-9) * 10
$array = Array(9,9,9) ; create a three dimensional array with 1000 elements (0-9) * 10 * 10
*** Look for more information posted seperately in the scripts section (end of post) ...
Source:
code:
Function Array($dx,optional $dy,optional $dz)
dim $i
dim $x[$dx]
if vartypename($dy) = "long"
dim $y[$dy]
if vartypename($dz) = "long"
dim $z[$dz]
for $i = 0 to ubound($y)
$y[$i] = $z
next
endif
for $i = 0 to ubound($x)
$x[$i] = $y
next
endif
$array = $x
EndFunction
Scripts:
code:; Example of loading and iterating over multi-dimensional arrays in KiXtart
; The following example loads a unique value into each element of a three dimensional array
$array = array(9,9,9)
for $x = 0 to 9
for $y = 0 to 9
for $z = 0 to 9
$array[$x][$y][$z] = "$x-$y-$z" ; the unique value is a string representation of the indexes
next
next
next
; Now re-iterate through the array and verify unique values
for $x = 0 to 9
for $y = 0 to 9
for $z = 0 to 9
if $array[$x][$y][$z] <> "$x-$y-$z"
?"ERROR IN ARRAY !!!"
endif
next
next
next
Author:
Shawn Tassie (shawn.tassie@cgi.ca)
[ 24 November 2001: Message edited by: Shawn ]