REDIM
Syntax
REDIM [ Scope ] Variable_Name as Value_Type
|
Argument |
|
Description |
|
|
Scope |
V5 |
Optional. Default = "LOCAL".
| |
|
V6 |
| ||
|
Variable_Name |
V5 |
The name of the variable. |
|
|
Value_Type |
V5 |
The variable type is indicated through the Value_Type, a single character:
|
|
Description
REDIM is used to change the size of an array. All existing values in the array are lost when an array is REDIMmed.
To preserve existing values in the array use the <ARRAY>.SIZE() method. An alternative way to add new entries to an array, and simultaneously increase the array size, is to use the '[]' syntax. See example below.
Example
Re-dimensioning an array.
|
dim ary[3] as C ary[1] = "a" ary[2] = "b" ary[3] = "c" ary[4] = "d" ERROR: array index out-of-bounds redim ary[4] as C ary[4] = "d" ?ary[1] = "" 'Note how the .resize() method preserves existing array entries. ary.resize(5) ary[5] = "e" ?ary[4] = "d" 'Add a new entry to the array and increase its size ary[] = "f" ?ary[6] = "f" ary[] = "g" ?ary.size() = 7 |
See Also
Language Reference, Reserved Words, DIM, DELETE, TYPE ... END TYPE
Supported By
Alpha Five Version 5 and Above