255 Dimensions Per Array in Interpreter, 7 in Compiler (33735)



The information in this article applies to:

  • Microsoft QuickBASIC 1.0
  • Microsoft BASIC Compiler
  • Microsoft BASIC Interpreter for Apple Macintosh 2.0
  • Microsoft BASIC Interpreter for Apple Macintosh 2.1
  • Microsoft BASIC Interpreter for Apple Macintosh 3.0

This article was previously published under Q33735

SUMMARY

The following information applies to Microsoft QuickBASIC Version 1.00, BASIC Compiler Version 1.00, and BASIC Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

The maximum number of dimensions an array can have in the interpreter is 255, which may be more than you could ever use because memory is quickly used up by arrays with a large number of dimensions.

The maximum number of array dimensions a compiled program can have is seven.

The maximum number of array elements per dimension allowed in both the interpreter and compiler is 32,767.

MORE INFORMATION

Please remember that base elements of arrays start with element number zero (OPTION BASE 0) by default. In other words, DIM X(20) dimensions X with 21 elements, X(0) through X(20). If you do not ever use element zero in any dimension, you should invoke OPTION BASE 1 at the top of your program to save memory. This process is especially important if you make an array with a large number of dimensions.

The following array has seven dimensions with two elements per dimension, giving it a total of 128 (2 to the power of 7) elements:
   OPTION BASE 1
   DIM X(2,2,2,2,2,2,2)
				
If you took out the OPTION BASE 1 statement, the default base element of the array would be "0", and the array would have three elements per dimension, giving a total of 2187 (3 to the power of 7) elements. Notice how the OPTION BASE greatly affects allocated memory if you have a multi-dimensional array.

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB33735