arraychange(
TEXT
,
NEWVALUE
,
ITEM
,
SEPARATOR
)

The arraychange( function changes the value of a single data item in a text array or a data array (see Text Arrays and Data Arrays).


Parameters

This function has four parameters:

text – The array that contains the data you want to change.

newvalue – The new value of the specified array element.

item – The number of the data item you want to change. 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.)

separator – Is the separator character or characters for this array. This parameter is omitted if the target array is a data array.


Description

The arraychange( function changes a single value inside an array. Only the one item is changed, all the other items in the array remain the same.

arraychange("red,green,blue","orange",2,",") ☞ red,orange,blue
arraychange("red,green,blue","orange",3,",") ☞ red,green,orange
arraychange("red,green,blue","orange",4,",") ☞ red,green,blue
arraychange("red,green,blue","orange",-1,",") ☞ red,green,orange

Working with Data Arrays

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

arraychange(myDataArray,8,4) ☞ 3,hello,49,8,7.21,blue
arraychange(myDataArray,8,7) ☞ arraychange( cannot change values outside its array bounds

Error Messages

array( function: ARRAY parameter must be text. – The array (first parameter) must be text, not a number.

array( function: ITEM parameter must be numeric. – The item (second parameter) must be text, not a number.

array( function: SEPARATOR parameter must be text. – The separator character (third parameter) must be text, not a number.


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0, but the item number can now be negative to designate that it should be counted from the end of the string instead of from the beginning. More than one character is now allowed for use as the separator parameter.