Revision [9900]
This is an old revision of KeyPgPreserve made by JeffMarshall on 2007-07-22 20:49:29.
PRESERVE
Used with KeyPgRedim Redim to preserve contents will resizing an array
Syntax:
Description:
Used with KeyPgRedim Redim so that when an array is resized, data is not reset but is preserved. This means when the array is enlarged that only new data is reset, while the old data remains the same.
In arrays with more than one dimension, only the first subscription can be redimensioned (arrays are stored in row-major order, so it's the first, not the last subscription).
Examples:
ReDim array(1 To 3) As Integer
Dim i As Integer
array(1) = 10
array(2) = 5
array(3) = 8
ReDim Preserve array(2 To 10)
For i = 2 To 10
Print "array("; i; ") = "; array(i)
Next
Dim i As Integer
array(1) = 10
array(2) = 5
array(3) = 8
ReDim Preserve array(2 To 10)
For i = 2 To 10
Print "array("; i; ") = "; array(i)
Next
Differences from QB:
- PRESERVE wasn't supported until PDS 7.1
See also:
Back to Array Functions