Kevin,
Single dimensional or multi dimensional foxpro array ?
Internally foxpro arrays are derived from the 'generic' array type, and are implemented as a single dimensional array.
Multiple dimensions are achieved by calculating the offset from the row/column specified.
That is why you can also access them with a single index (like in FoxPro).
What you can do is something like this:
Code: Select all
FUNCTION Start() AS VOID
PUBLIC ARRAY aFoxArray(3)
aFoxArray := 42 // fill the array with 42
LOCAL aArray as ARRAY
aArray := aFoxArray
ShowArray(aFoxArray)
ShowArray(aArray)
WAIT
RETURN
The array is still a fox array but recognized as array by the runtime.
However some operations will still not be possible. For example you can't assign a subarray.
To "truely" convert you will need to do something like this:
Code: Select all
LOCAL aArray as ARRAY
aArray := Array{ (ARRAY) aFoxArray}
This will create a new array and will add all elements of the FoxPro array to it.
You can see the difference, since the ShowArray() function will use parentheses for FoxPro arrays and will use square brackets for 'normal' arrays.
You will have to add the ARRAY cast because the PUBLIC array is not really typed (like in FoxPro) so the compiler does not know which constructor of the array class to call.
Of course this also works with LOCAL ARRAY (which create a local array) or with DIMENSION (which creates a private array)
If you declare the array with 2 dimensions (like in PUBLIC ARRAY aFoxArray(2,3) )
then the resulting array will have a single dimension with all of the elements of the FoxPro array duplicated.
Robert