REDIM

From Liberty BASIC Family
Revision as of 03:04, 11 October 2023 by StPendl (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

Description

Changes the size of an array. An array that has been DIMensioned to hold a certain number of elements can be REDIMensioned to change the number of elements that it can hold.

Syntax

  1. one-dimensional array
    redim array(size)
  2. two-dimensional array
    redim array(size1, size2)

Hints

REDIM erases any previous contents of an array and sets all of the elements to zero (0), or to an empty string ("") if it is a string array. Any data stored in the array before the REDIM must be read back into the array (re-stored) if it is still to be used.
REDIM is useful if the number of data items your program needs to save to an array changes from the initial DIM size.
You cannot change a one-dimension array to a two-dimension array (or vice versa) with REDIM.

Example

' code snippet...
    dim cust$(1)  'dimension the array
    '
    '
    '
    'when we know that there are 510 customers perform a REDIM
    redim cust$(510)
    'all the data was erased from the array
    'now read in the customer records

Useful Procedures

' Place a useful function or sub using this keyword here