I need help with DefData and Arrays

BlitzMax Forums/BlitzMax Beginners Area/I need help with DefData and Arrays

There are two problems here.

The first, as mentioned, is that the second array index in levelArray:Short[399, 14] ranges from 0 to 13, not 0 to 14.

The second is the difference between having Debug mode turned on or off. With Debug on the 'out of bounds' array index of 14 will cause a crash and an error message.

With Debug off there is no bounds checking. If you assign a value to levelArray[x,14] the compiler will blindly attempt to do this even though the 14 is larger then the maximum allowed index of 13. The result is that the value is assigned to the wrong memory location. This can still cause a crash if that location is not available to your program. But with the 399 there is plenty of extra space in the array so your program never crashes. It just puts the value into the wrong array element.