arrayrelocate(
ARRAY
,
POSITION
,
NEWPOSITION
,
COUNT
,
SEPARATOR
)

The arrayrelocate( function moves one or more items to a new position in a text array or a data array (see Text Arrays and Data Arrays).


Parameters

This function has five parameters:

array – The original array that contains the item(s) you want to move.

position – The number of the first item you want to move. The first item is 1, the second item is 2, the third is 3, etc., or you can use negative values, -1 (last item), -2 (second to last, etc.)

newposition – The new position of the first item you want to move. The first item is 1, the second item is 2, the third is 3, etc., or you can use negative values, -1 (last item), -2 (second to last, etc.)

count – The number of items to move. This parameter is optional, if omitted the count will be 1.

separator – Is the separator text for this array. This parameter is optional, if omitted, the first parameter must be a data array instead of a text array.


Description

This function returns a modified array, with one or more array items moved to a new position.

arrayrelocate("first,second,third,fourth,fifth",2,4,",") ☞ first,third,fourth,second,fifth
arrayrelocate("first,second,third,fourth,fifth",4,2,",") ☞ first,fourth,second,third,fifth
arrayrelocate("first,second,third,fourth,fifth",2,3,3,",") ☞ first,fifth,second,third,fourth

Working with a Data Array

This function works with both data and text arrays. Because Data Arrays have no separators between elements, the separator parameter is omitted when targeting a data array.

Suppose we have a data array, myDataArray, defined as below (noting that a data array can contain text, numeric, binary and other data types):

myDataArray = dataarray(3,"hello",49,43,7.21,"blue")

Then,

arrayrelocate(myDataArray,5,1) ☞ 7.21, 3, hello, 49, 43, blue
arrayrelocate(myDataArray,5,8) ☞ New item position is beyond end of array

See Also


History

VersionStatusNotes
10.0NewNew in this version.