07-22-2024, 03:36 PM
(This post was last modified: 07-22-2024, 03:43 PM by Kernelpanic.)
Quote:Pete's point is a good catch, which is that the `ReDim x(b)` line should produce the same error as the `ReDim y(7)` line. I assume it's just a bug, though I guess the QBasic behavior should be checked before saying that for sure.I don't know what happens internally, but the way I did it is described in the QBasic Programmer's Reference. And it works.
Usage of a variable for the bounds is different from a constant because the array has to be allocated/initialized at the position of the `Dim` statement, rather than at the start of the program or SUB/FUNCTION. This is similar to how `ReDim` works, the allocation takes place at the point of the `ReDim`, and it seems like the flag indicating the array is static never gets set when allocated this way. If the flag is missing then you're allowed to do a `ReDim`, so you don't get an error.
PS: And in the Quick Basic 4.5 manual; Dim and ReDim. Pretty extensive, and not that easy.