Removing Elements

SetLength


SetLength(array, numberOfElements)


In addition to adding elements, SetLength can remove them. If the numberOfElements parameter is less than the array's current length, the array is truncated to the numberOfElements.

x := [15, "xyz", {a: 2, b: 3}];
SetLength(x, 1);
After the code has executed, x has only one element: 15. Note that SetLength can only remove elements from the end of the array.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996