Microsoft KB Archive/32417

= &quot;Invalid Character&quot; in Compiler on DIM for Dynamic Array =

Article ID: 32417

Article Last Modified on 11/21/2006



This article was previously published under Q32417



SUMMARY
The compiler in QuickBASIC for Macintosh gives an &quot;Invalid character&quot; message for a DIM statement at compile time if an array is dimensioned using a variable or function in the subscript, and the &quot;Make All Arrays Static&quot; compiler option is selected (or DIM STATIC is used). This error occurs because a static array must be dimensioned with a constant or simple constant expression in the array subscript in the DIM statement.

To allow a variable or function in the array subscript in the DIM statement, you must make the array dynamic (by turning off the &quot;Make All Arrays Static&quot; option and by using DIM instead of DIM STATIC).

If some arrays need to remain dynamic while others are static, use the DIM STATIC statement to dimension static arrays and DIM to dimension dynamic arrays, and do not select &quot;Make All Arrays STATIC&quot; (in the &quot;Options...&quot; item of the Run menu).



MORE INFORMATION
The following code gives an &quot;Invalid character&quot; error at compile time only when you select the &quot;Make All Arrays STATIC&quot; compiler option: B=180 DIM X(B)         ' Array must be dynamic. DIM Y(SQR(16))   ' Array must be dynamic. The following code always gives &quot;Invalid character&quot; at compile time with or without the &quot;Make All Arrays STATIC&quot; option: B=180 DIM STATIC X(B)       ' Always static when compiled. DIM STATIC Y(SQR(16)) ' Always static when compiled. The following code compiles successfully with (or without) the &quot;Make All Arrays STATIC&quot; compiler option selected: DIM X(5 * 36) ' Can be static or dynamic. DIM Y(4)      ' Can be static or dynamic. PROGRAMMING NOTES:

Arrays are always dynamic (never static) in the interpreter in QuickBASIC. In the compiler, you can specify static or dynamic arrays.

Note that QuickBASIC for Macintosh offers no REM $ metacommand feature to specify static or dynamic arrays.

Additional query words: MQuickB

Keywords: KB32417

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.