Show/Hide Toolbars

XSharp

The FoxPro dialect in X# has its own Array type. This type is not declared with an AS keyword, but the array type is derived from the context.
The following lines of code all generate a FoxPro compatible array:

 

LOCAL ARRAY aTest(1,2)     // LOCAL ARRAY
PUBLIC ARRAY aPublicArray[10]   // PUBLIC ARRAY
DIMENSION AnotherArray(3,4)   // DIMENSION with parentheses , but angled brackets are supported too
DECLARE ThirdArray[10]     // DIMENSION with angled brackets, but parentheses are supported too

The elements of a Foxpro compatible array are all USUAL.
FoxPro arrays cannot be dynamically sized with AAdd(). To resize them you need to add a DIMENSION statement with new dimensions.

Internally FoxPro arrays are single dimensional arrays. But you can also (re)dimension them as two dimensional.
So the 3rd array in this example can also be treated as a single dimensional array of 12 elements.

 

We advise to use angled brackets to access elements of a FoxPro array. This is not ambiguous and the compiler can resolve that at compile time.

If you want to use parentheses to access FoxPro array elements you need to enable the /fox compiler option. This compiler option also enables the behavior that assigning a single value to a FoxPro array will result in assigning that value to all elements in the array.

 

Internally FoxPro arrays are implemented as a class that derives from the generic XBase array type.

So all functions in the X# runtime that take an array as parameter will also accept a FoxPro array.
When there is different behavior between the FoxPro implementation of a function or the Xbase implementation then this will be handled at runtime.

Implementation

The ARRAY type is implemented in the class XSharp.__FoxArray.

The Usualtype of ARRAY has the value 5