Skip to content

DELETE ARRAY

Delete Array Elements

This directive deletes elements of an array.

DELETE ARRAY array-name [(pos1,count1)[,(pos2,count2)
[,(pos3,count3)]]]
array-name
is the name of an array followed by the left square bracket (or optionally the left parenthesis in the case of a numeric array).
pos1
is the starting position where deleting begins.

pos2
pos3

count1
is the number of elements that are deleted.

count2
count3

Deleting indices in a multi-dimensional array changes the dimensions of the array. In a multi-dimensional array, deleting all the elements from any dimension essentially deletes the whole array, i.e. in a 4x4x4 array, doing a DELETE ARRAY A[(0,4)] turns the array into a 0x4x4=0 elements array.

If there is not enough memory to expand the array during DELETE ARRAY, an ERR=33 results.

If any of the positions or counts are not integers, an ERR=41 results.

If the array does not exist, an ERR=42 results.

If an attempt is made to DELETE elements before the starting position of the dimension, an ERR=42 results.

If an attempt is made to DELETE elements after the last element in the dimension +1, an ERR=42 results.

00060 DIM A$[5]; FOR X = 0 TO 5; A$[X] = STR[X]; NEXT X

creates a one-dimensional string array and populates it with the following values:

A$[0] = “0”
A$[1] = “1”
A$[2] = “2”
A$[3] = “3”
A$[4] = “4”
A$[5] = “5”

DELETE ARRAY A$[(3,1)]

deletes the third array element, which moves the fourth and fifth entries into the third and fourth elements:

A$[0] = “0”
A$[1] = “1”
A$[2] = “2”
A$[3] = “4”
A$[4] = “5”

DELETE ARRAY A$[(2,2)]

deletes the second and third array elements, which moves the fourth entry into the second element:

A$[0] = “0”
A$[1] = “1”
A$[2] = “5”

INSERT ARRAY directive

From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF