Ruud (etal)Speaking of arrays ...
Hope you can make sense out of the following scrap of code. I'm trying to enumerate nested arrays using the FOR-EACH-IN-NEXT construct... What I bumped into was the following bit of esoterica and wanted to know if this was desirable behavior (on KiXtart's part, not mine)...
The following script enumerates an array of numbers (twice) then attempts to enumerate an array of arrays (twice). Run this script with beta2a and you get the following syntax error...
Script error : expected '[' !
for each $array in $array4
Uncomment the commented line and everything works fine...
I'm bringing this to your attention because my gut tells me that this is not something you want happening and that there may be a problem in the way KiXtart is initializing (or in this case, not initializing) these transient in-variables.
Afterthink:
Does this have to do with the fact that you can't use arrays in some expressions - therefore once it gets casts to an array in the first loop - you can't use it again in the second loop - unless you recast it to anything but an array ?
After-Afterthink:
no,no,no - it's because in the second array enumeration, $array is already cast as an array and FOR-NEXT is looking for brackets !
code:
break on
; Enumerate an array of numbers (twice)
$array1 = 1,2,3,4
?"once..."
for each $number in $array1
?$number
next
?"twice..."
for each $number in $array1
?$number
next
; Enumerate an array of arrays (twice)
$array2 = 1,2,3,4
$array3 = 1,2,3,4
$array4 = $array2,$array3
?"once..."
for each $array in $array4
? $array[0]
? $array[1]
? $array[2]
? $array[3]
next
; $array = 0 ; <--- uncomment this line
?"twice..."
for each $array in $array4
? $array[0]
? $array[1]
? $array[2]
? $array[3]
next
exit
Shawn.
[This message has been edited by Shawn (edited 04 May 2001).]