"Array Already Dimensioned" if 2nd DIM for Static Array in IF (35658)
The information in this article applies to:
- Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
- Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
- Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0
This article was previously published under Q35658 SUMMARY
Static arrays are dimensioned at compile time, regardless of whether
or not the DIM statement is in the program flow of control. For
example, if the DIM for a static array occurs in an IF statement that
would never be executed at run time, the array will still be
dimensioned at compile time. If you attempt to dimension a given
static array more than once in a source file, you will get an "Array
Already Dimensioned" error on the second DIM statement at compile
time, as in the following example:
10 x = 1
20 IF x = 2 THEN DIM array(14)
25 IF x = 1 THEN DIM array(25) ' "Array Already Dimensioned" compile-time
30 array(21) = 4
40 PRINT array(21)
This behavior occurs in all versions of Microsoft QuickBasic for the
IBM PC, in the Microsoft Basic Compiler Versions 5.35 and 5.36 for
MS-DOS and Versions 6.00 and 6.00b for MS-DOS and MS OS/2, and in
Microsoft Basic PDS Version 7.00 for MS-DOS and MS OS/2.
Modification Type: | Major | Last Reviewed: | 11/18/2003 |
---|
Keywords: | KB35658 |
---|
|