REDIM

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Core Language > Data types and variables >

REDIM

 

Description

 

Used to re-dimension a previously declared arrays.

 

Syntax

 

Syntax for standard arrays:

REDIM [PRESERVE] VariableName[(subscripts)]

 

Syntax for absolute arrays:

REDIM AbsoluteVariableName[(subscripts)] [AT address]

 

Returns

 

None

 

Parameters

 

Remarks

 

REDIM will preserve previous array data only if optional PRESERVE clause will be specified.

If PRESERVE is not present an empty array will be created and previous data will be deallocated.

 

If no subscripts will be indicated, array will be deallocated. So:

ReDim AnyArray

will just un-dimension AnyArray.

 

Restrictions

 

See also

 

Dim

 

Examples

 

'----------------------------------
'---Arrays                      ---

'----------------------------------
Dim MaxItems As Long Value 10000

Dim MyArray(MaxItems) As String

 

'---Undimensioned array redimensioned later

Dim MyUndimensionedArray() As String

'...

ReDim MyUndimensionedArray(MaxItems)

 

 

'----------------------------------
'---Example using absolute array---

'----------------------------------
Dim Mystring AS STRING
Mystring = "AA"
Dim MyArray(Len(MyString)) AS BYTE AT STRPTR(MyString)

'---Array containing 2 byte values 65,65

 
Mystring = "AAAA"
REDIM MyArray(Len(MyString)) AT STRPTR(MyString) ' Array containing 4 byte values 65,65,65,65