REDIM

Syntax

REDIM [ Scope ] Variable_Name as  Value_Type

Argument

 

Description

Scope

V5

Optional. Default = "LOCAL".

  • "LOCAL"

  • "SHARED" = Variable exists as long as a window is open. Even if you change the layout that is loaded in the window (by using the File > Open… command from within the Form or Browse window), the variable continues to exist.

  • "GLOBAL" = Variable exists as long as Alpha Five is running, until you close the current database.

V6

  • "PRIVATE" = The variable is visible only inside its class.

Variable_Name

V5

The name of the variable.

Value_Type

V5

The variable type is indicated through the Value_Type, a single character:

  • "C" = character

  • "D" = date

  • "N" = numeric

  • "L" = logical

  • "P" = pointer

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