Please enable JavaScript to view this site.

A-Shell Development History

Compiler (edit 464) and corresponding runtime enhancement: New system function .EXTENT() returns the current extent of a specified dimension of a specified array. This is primarily of use with dynamic and especially AUTO_EXTEND arrays, but works with fixed arrays as well. Example:

DIMX ARY(1,5,25),S,20,AUTO_EXTEND

MAP1 N,I,2

INPUT "Enter an integer: ",N

ARY(N,1,1) = "THIS IS  ROW "+STR(N)

 

PRINT .EXTENT(ARY())    ! extent of 1st dimension (dflt 1) (>=N)

PRINT .EXTENT(ARY(),2)  ! extend of 2nd dimension  (5)

PRINT .EXTENT(ARY(),3)  ! extend of 3rd dimension  (25)

PRINT .EXTENT(ARY(),4)  ! extend of 4th dimension  (-1 for error)

 

The above program will output predictable values - 5 and 25 for the extent of the 2nd and 3rd dimensions, since those are fixed in the array definition. But the extent of the first dimension will depend on the AUTO_EXTEND activity. For example, if N = 75, the returned value might be 85 (since when arrays are auto-extended, they are extended somewhat beyond the minimum size needed at the time, in order to minimize the need for subsequent auto-extensions).

For an invalid dimension (4 in the example above), or for an array that has not yet been DIMXed (or has been un-dimensioned), the return value is -1. (This last fact eliminates the need to maintain a static flag variable indicating whether a particular dynamic array has been DIMXed yet, as was sometimes necessary previously.)