could we illustrate a little this note that is found at the REDIM doc page? The page is well documented but the note (below) still holds intrinsic difficulty.
For instance, can I deduce that if I make a multidimension array and just resize the last dimension then I can safely use PRESERVE? (redim preserve array(a)(b)(c) with modifying c only)
Not an urgent task anyway. Thanks.(redim documentation page)
NOTES:
ReDim Preserve may not work as expected in all cases:
Preserve's current behavior is to keep the original data contiguous in memory, and only expand or truncate the size of the memory.
Its behavior (with a single dimension) is well-defined only when the upper bound is changed. If the lower bound is changed, the current result is that the data is in effect shifted to start at the new lower bound.
With multiple dimensions, only the upper bound of only the first dimension may be safely increased. If the first dimension is reduced, the existing mappable data may be lost. If lower-order dimensions are resized at all, the effects can be hard to predict.
ReDim cannot be used on fixed-size arrays - i.e. arrays with constant bounds made with Dim. This includes the fixed-size arrays contained in UDTs (user-defined Types). This also includes fixed-length arrays passed as parameters in a function. FreeBASIC cannot prevent you trying this at compile-time, but the results at run-time will be undefined.
Using ReDim within a member procedure with an array that contains an instance of the object class is undefined, and will [hopefully] result in horrible crashes.
For use of ReDim (resizing) with a complex expression, (especially if the array expression itself contains parentheses), the array expression must be enclosed in parentheses in order to solve the parsing ambiguity.