Microsoft KB Archive/184969

= PRB: SET COMPATIBLE ON Causes Problems with Arrays =

Article ID: 184969

Article Last Modified on 5/2/2001

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 3.0 for Macintosh

-



This article was previously published under Q184969



SYMPTOMS
If SET COMPATIBLE is ON and an array is redimensioned, the array loses it previously saved values and sets the current value to logical false (.F.).



CAUSE
When SET COMPATIBLE is set to ON or DB4, Visual FoxPro overwrites any existing array with a variable of the same name when a STORE command or assignment is made.



RESOLUTION
If the array needs to retain its contents, try one of the following:
 * Issue SET COMPATIBLE OFF in the program or form.
 * Add COMPATIBLE=OFF to the Config.fpw file.
 * From the Tools menu, select Options. In the Options dialog box, click the General tab and clear the dBase compatibility check box.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
This can be demonstrated when an array is redimensioned within a loop. To reproduce the problem, create a new program and enter the following code: CLEAR SET COMPATIBLE ON        && Or SET COMPATIBLE DB4 DIMENSION atest(5)    && Dimension to some value. FOR i = 1 to 10 DIMENSION atest(i) Atest(i)="Test "+ALLTRIM(STR(i)) ENDFOR

DISPLAY MEMORY LIKE atest When the code is executed, the array has 10 elements, but only the last element contains a value. The other elements contain a logical false (.F.).

