Please enable JavaScript to view this site.

A-Shell Reference

This statement will re-dimension an array originally created with DIMX.

DIMX varnam(sub1,...,subn),<type>,<size>

...

REDIMX varname(sub1,...subn)

where sub1 thru subn are the desired extents of each dimension.

It can also be used to deallocate an array by setting the extents to zero. For example:

DIMX ARY(50,100),X,25          ! allocate the array

...

REDIMX ARY(0,0)                ! deallocate it

 

You can also use REDIMX to deallocate an ordered map, except in that case instead of specifing an explicit extent of zero, you leave the parentheses empty:

DIMX $ARY, ORDMAP(VARSTR;VARSTR)    ! allocate the ordered map

...

REDIMX $ARY()                       ! deallocate it

 

Notes

The REDIMX statement must occur after the corresponding DIMX (both during compilation and at runtime). If the compiler sees the REDIMX first, it will report an unmapped variable. If the runtime sees the REDIMX first (except for the exception noted below), it will report error 30 (re-dimensioned array - same error as you get when attempting to use DIMX a second time).
The one exception to this rule is that a runtime attempt to REDIMX an array to a size of 0 will not complain if the array has not yet been allocated. This allows you to add a REDIMX VARNAME(0,…,0) to free up an array in an error recovery routine, without having to check whether the array had actually been allocated yet.
You cannot change the number of subscripts; you can only change the maximum value(s) of the subscript(s).
The REDIMX statement can not specify a variable type or size; thus you cannot change the original type or size.
The original contents of the array will be preserved ONLY if all dimensions beyond the first (for multi-dimensional arrays) are preserved. For example, if you start with DIMX A(P,Q,R), and then re-dimension using REDIMX A(X,Y,Z), the contents will be preserved only if Y=Q and Z=R (i.e., only the first dimension was changed).
The MALLOC trace option will trace DIMX and REDIMX memory allocations (along with most other memory allocations/de-allocations), making it a useful debugging tool.

 

History

2009 April, A-Shell 5.1.1145: REDIMX added to a-Shell

2010 August, A-Shell 5.1.1189:  Enhanced support removing an array by setting its subscripts to zero.