Kevin,
The potential problem that I see with FoxPro arrays is that they are not really multi dimensional, but they emulate multi dimensions. Consider the following code
Code: Select all
DIMENSION myarray(5,2)
? ALEN(myarray)
myarray[1] = 10 && this sets element [1,1]
myarray[1,2] = 12
? myarray[1,1] && 10
? myarray[2] && 12, so this reads element [1,2]
FOR i = 1 TO 10
? i, myarray[i]
myarray[i] = i
NEXT
* you can even access undefined columns and rows
* in other xbase dialec ts all of the following would crash
? myarray[2,4] && 6 ?
? myarray[3,3] && 7 ?
? myarray[9] && 9 ?
In most of the other dialects this mixing of single and multi dimensional approach will not be possible.
When you declare an array as [5,2] then the first element of the array is a sub array of 2 elements.
Assigning 10 to it would remove the sub array in the first element and accessing it with a 1,1 index later would cause an exception because the sub array has been replaced with a single numeric value.
And in other XBase dialects accessing element myarray[2] would return an array of 2 elements and not a single value.
I am sure that internally FoxPro uses single dimensional arrays always and it somehow calculates the position in this array by calculating a single dimensional offset in the array from the dimensions used.
And FoxPro even allows to use positions outside of what has been defined !
I personally think this was a design flaw in FoxPro. An array that is declared as multi dimensional should not allow to be treated as single dimensional and accessing 'undefined' positions show throw an exception.
Robert