The -fox2 compiler option is enabled for foxpro compatible array support. It enables / disables the following features:
•Assigning a single value to an array will fill the whole array with that value
•Support for parenthesized array access.
If the compiler encounters code that might be an array access such as Foo(1,2) then it will check to see if Foo() is a local or field declared as a foxpro array. If that is the case then the array element will be accessed. If Foo is not declared, then this might be an array access for a dynamic memory variable declared outside of the scope of the current method / function. The compiler will then generate code to resolve this at runtime (just like FoxPro does)
The -fox2 compiler options MUST be used together with the -memvar compiler option and the FoxPro dialect.
LOCAL a
Dimension a(10)
a = 42 // With the /fox2 compiler option this will fill the array with 42.
// Without the option the variable will be changed from an array to a number
or
Function Main()
Dimension foo(2,5)
foo = 42 // with /fox2 this fills the array
? foo(1,2) // with /fox2 this returns element 1,2. Without /fox2 this will call the Foo function below
? Foo[1,2] // this always returns element 1,2
FUNCTION Foo(n1, n2)
? n1, n2
RETURN n1 * n2
The fox2 compiler option generates some extra code to decide at runtime which action to take.
It is only recommended for code that really needs this feature.
You can use #pragma options to enable / disable fox2 for some source files or even some functions