"Overflow," "Subscript Out of Range," >32,767 Array Elements (32787)
The information in this article applies to:
- Microsoft QuickBASIC 4.0
- Microsoft QuickBASIC 4.0b
- Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0
- Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
- Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
This article was previously published under Q32787 SUMMARY
Page 156 of the "Microsoft QuickBasic 4.0: Basic Language Reference"
for Versions 4.00 and 4.00b and the "Microsoft Basic Compiler 6.0:
Basic Language Reference" for Versions 6.00 and 6.00b for MS-DOS and
MS OS/2 correctly states that an array dimension can have subscripts
from -32,768 to 32,767. This is also stated on Page 103 of the
"Microsoft Basic 7.0: Language Reference" manual for Microsoft Basic
Professional Development System (PDS) Version 7.00. For example DIM
Z%(-2000 TO 3000), which has 5001 elements, is legal.
However, these pages fail to mention that the TOTAL NUMBER of elements
in any one dimension of an array cannot exceed 32,767 (32K minus one).
For example, the following DIM statements are not allowed because they
make an array with more than 32,767 elements in one dimension:
DIM X(-10000 TO 25000) ' 35,001 elements is too many.
DIM A%(0 TO 32767) ' 32,768 elements is one too many.
To make an array that exceeds 32,767 total elements, you must
dimension it with two or more dimensions (making sure that no one
dimension has more than 32,767 elements; you must also compile with
the /AH option).
Below is an explanation of array usages that could give one of the
following errors:
"Overflow," "Math Overflow," "Subscript Out of Range,"
"Array Too Big," "Out of Memory"
Modification Type: | Minor | Last Reviewed: | 1/8/2003 |
---|
Keywords: | KB32787 kbAudDeveloper |
---|
|