Modify the size of any array dimension

redim()

Command to modify the size of any array dimension

Version >= 6.2.0


SYNTAX

redim(fld_rec, dim, newSize)

That method will change the fld_rec dimension dim to the specified newSize.

fld_rec

Field or record array to re-dimesion

dim

The dimension to change the size (value 1 to 4)

newSize

The new dimension size

The existing data remains execept in case of reducing the dimensions, in which case the removed dimensions data will disapear. When increasing the dimension, the new data will be initialised as if it were a new field.

Considerations:

  • Only field/record dimensions already defined could be changed

  • The dimension size must be between 1 and 65534

  • Sys special variables, !file related fields or local variables can’t be redim’ed

Returns 0 if the redim operation is successful.


EXAMPLE

Here you can see how to redim a field, record and subrecord:

!record ArrayRec[2] {
    !record SubRec[2] {
        txt,,a8
    }
    num,,i4[2]
    !record SubRec2 = ArrayRec.SubRec
}

/* Increase field ArrayRec.num dimension to 4 */
redim(ArrayRec.num, 1, 4)

/* Increase SubRecord ArrayRec.SubRec & ArrayRec.SubRec2 dimension to 3 */
redim(ArrayRec.SubRec, 1, 3)

/* Increase Record ArrayRec dimension to 3 */
redim(ArrayRec, 1, 3)

RELATED TOPICS

Field dimensions

Field flags

Auto-resizeable field flag

dim()