bas7qck.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Array Out of Memory
  10 Questions                                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
I get a "Subscript out of range" error when I declare a huge dynamic
array even though I have plenty of memory. Why?
 
When you use the huge (/ah) option, you can declare dynamic fixed-length
string arrays and dynamic numeric arrays to a size greater than 64 Kbytes.
However, if you are declaring an array and the size of its elements
isn't an even power of 2, the array will be limited to 128K.
 
You can obtain huge arrays larger than 128K by padding the type to become
a size that is a power of 2. For example:
 
     TYPE Padded
       A   AS DOUBLE
       B   AS STRING * 215
       Pad AS STRING * 33   ' To pad out the type to 256 bytes
     END TYPE
     Max = 430
     REM $DYNAMIC
     DIM NewOne(Max) AS Padded