resize()

 

The resize() method resizes the given single-dimensional array to the specified size. If the new size is bigger than the previous array size, the elements will be appended to the end of the array. If the new size is smaller, the excessive elements will be deleted from the end of the array and all the data in them will be lost.

This method accepts a single parameter which is an expression returning a positive integer.

 

array_variable.resize(size)

 

Here is a simple example:

 

DEFINE ar DYNAMIC ARRAY OF INT

...

FOR i = 1 TO 10           #the array has 10 elements

   LET ar[i]=i

END FOR

 

CALL ar.resize(100) #the array is resized to 100 elements, 90 of which contain 0

CALL ar.resize(5)   #the aray is then resized to 5 elements, so values 6, 7, 8, 9,

                    #and 10 are discarded together with 0 values