append()/appendElement()

 

The Append() and AppendElement() methods add a new array element after the last array element. The size of the array will increase by 1. The Append() method accepts one parameter which is the value to be inserted into the added array element:

 

array_variable.append(value)

 

The AppendElement() method does not need any parameters and adds a new element with the NULL value. The syntax of the method is as follows:

 

CALL ar.AppendElement()

 

The methods are applicable only to dynamic arrays and do not have any effect on the static ones.

 

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.append("element 6")             #adds 6th element to the array

CALL ar.appendelement()                 #adds 7th element with the NULL value

DISPLAY ar.GetLength()                  #displays "7"