<array row resize parameters>
──┬─<array row>─────────────────────┬─ , ──<new size>──────────────────►
└─<procedure reference array row>─┘
►─┬─────────────────┬──────────────────────────────────────────────────┤
└─ , ─┬─ RETAIN ──┤
├─ DISCARD ─┤
└─ PAGED ───┘
<new size>
──<arithmetic expression>──────────────────────────────────────────────┤
In this form of RESIZE statement, the first parameter is an array row, a one-dimensional array whose elements are of some array class: BOOLEAN, COMPLEX, DINTEGER, DOUBLE, INTEGER, REAL, or a character type.
The RESIZE statement causes the size of the designated row to be modified as specified by the new size. The resize options have the following effects:
|
Option |
Effect |
|---|---|
|
DISCARD |
If the new array is not paged, the current contents of the array row are discarded and initialized to zero. If the array is paged, or becomes paged during the resize, then the contents for the array row are retained as described for the RETAIN option. |
|
RETAIN |
Current information in the array row is retained only if it fits in the new size. If the new size is smaller than the old size, data in the lost elements is discarded. If the new size is larger, the data in the new elements is initialized to zero. |
|
PAGED |
The resized array is a paged array. PAGED implies RETAIN with respect to the contents of the array. PAGED is not valid for a procedure reference array row because a procedure reference array cannot be paged. When the size of the new array is less than the currently specified SEGARRAYSTART, the new array will be resized to the specified size, but will not be paged. |
If no third parameter appears and the array is not already paged, DISCARD is assumed. If no third parameter appears and the array is already paged, RETAIN is assumed.
If PAGED is not specified but the array is already paged, the array will remain paged. In this case, the third parameter is ignored and RETAIN is assumed.
If PAGED is not specified, the array is not already paged, and the <new size> exceeds the maximum length of a LONG array, then the array will automatically be paged. In this case, the third parameter is again ignored and RETAIN is assumed. Only the pages that are required to RETAIN the old data are copied from the unpaged array to the paged array. Any additional pages are not allocated until an index in the page is referenced.
When resizing an array that has not been referenced (for example, an untouched array), the <new size> is used to modify the length of the untouched descriptor, and the array remains untouched. The determination of the array's segmentation is deferred until the array is referenced.
Management of array segmentation is controlled by the array segmentation start size. An array row is paged if its declared length exceeds the array segmentation start size, unless otherwise declared as LONG or DIRECT. The array segmentation start size is displayed and set using the SEGARRAYSTART system command. An array that is not declared as LONG or DIRECT is paged when it is first referenced only if the declared (or resized untouched) length exceeds the current setting of SEGARRAYSTART. Refer to the System Commands Reference for more details on the SEGARRAYSTART command.
An array that is initially declared (or resized untouched) to be shorter than or equal to the current SEGARRAYSTART size is allocated as an unpaged array when referenced. It can be resized to become paged by using the PAGED option if the <new size> value exceeds SEGARRAYSTART.
When a paged array is first referenced, the page table dope vector (SEGDOPE) is allocated to contain untouched descriptors for the pages necessary for the array size. An individual page of the paged array is not touched until an index in that page is referenced.
When a paged array is resized and the new size of the array is smaller than the old, any pages that are no longer required are deallocated and their content is discarded. The SEGDOPE entries of any deallocated pages remain touched with a length of zero. Any pointers to these pages are invalid until reassigned or resized back into range. Note that resizing a paged array to a <new size> of zero will deallocate all pages of the array. If the purpose of the RESIZE to zero is simply to clear the array and RESIZE it to its current size, use the DEALLOCATE statement, as it accomplishes this more efficiently.
When a paged array is resized and the new size is larger than the old array, the page table dope vector is increased as necessary and updated with untouched descriptors. If the old array was previously segmented and the last page was touched (but less than page size in length), the new words added to the page are initialized to zero.
If the new array row size is less than the old, any pointer variable that now points beyond the end of the array row is set to the uninitialized state.
The value of the new size is integerized with rounding, if necessary, to specify a new size, Sn, which is interpreted as a number of elements for the resized array row. If the array row is an original array, then its size is changed to Sn. If the array row is a referred array and the original array has a different element size, the original array is resized to have just enough elements to hold Sn elements of the referred array row.
When an original array is resized, any referred arrays with element widths different from those of the original array are assigned the size they would have had if the original array had been declared at its new size and the referred array had been created from the original by array equivalence or array reference assignment.
When a resize of a referred array causes a resize of an original array, the size calculations are performed with the element widths Wn for the resized referred array and Wo for the original array. The new size of the original array, So, is the following:
So:= (Sn * Wn + Wo - 1) DIV Wo
So* Wo can exceed Sn * Wn . The new size, Sr, of any referred array with element width Wr that is based on the resized original array is the following:
Sr:= (So * Wo) DIV Wr
Wr is equal to Wn for the explicitly resized referred array, and the net calculation is the following, which can exceed Sn.
Sr:= (((Sn * Wn + Wo - 1) DIV Wo) * Wo) DIV Wn
The explicitly resized array row can be slightly larger than requested, if the original array has a wider element width. For example, if arrays RA and EA are declared as follows then EA contains 36 elements:
REAL ARRAY RA[0:5]; EBCDIC ARRAY EA[0] = RA;
If the statement RESIZE(EA,50,RETAIN) is executed, the original array, RA, is resized to a new size of 9 words, calculated from the following:
So = (50 * 8 + 48 - 1) DIV 48 = 9
The actual new size of the referred array, EA, is then 54, calculated from the following:
Sr = (9 * 48) DIV 8 = 54
Because the second calculation truncates, Sr * Wr can be less than So * Wo, just as with array row equivalence or array reference assignment.
For example, consider the following statement, where H is a hexadecimal array row:
RESIZE(H,29,DISCARD)
The following table shows the size assigned to referred arrays for several combinations of referred and original classes. The diagonal of the table shows the size assigned to each original.
|
Referred Arrays |
||||
| Original |
Hexadecimal |
EBCDIC |
Real |
Double |
|
Hex |
29 |
14 |
2 |
1 |
|
EBCDIC |
30 |
15 |
2 |
1 |
|
Real |
36 |
18 |
3 |
1 |
|
Double |
48 |
24 |
4 |
2 |

