clear()

 

The clear() method is used to set all the elements to NULL (in a static array) or remove all the elements (in a dynamic array). This method accepts no parameters.

The syntax of the method is as follows:

 

CALL ar.Clear()

 

or

 

array_variable.clear()

 

It is not identical to the usage of the INITIALIZE TO NULL statement, because the statement removes only the values leaving the array elements intact.

The clear() method can also be used with multi-dimensional dynamic arrays.

 

DEFINE ar DYNAMIC ARRAY OF CHAR(15)

...

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

   LET ar[i]="element "||i

END FOR

 

CALL ar.clear()                  #the array has no elements