arraytoggle
ARRAY
,
VALUE
,
SEPARATOR

The arraytoggle statement “toggles” a value within an array.


Parameters

This statement has three parameters:

array – a field or variable that contains the array. The array will be modified “in place”, in other words, this is both the input and output array.

value – the value to toggle. If the array already contains an item with this value, that item will be removed. Otherwise, a new item containing this value will be added to the end of the array.

separator – the separator value for the array.


Description

The Arraytoggle statement “toggles” a value within an array. If the value exists within the array, it is removed. If the value does not exist within the array, it is added to the end of the array.

To illustrate this, let’s assume we have a variable named colors that contains a comma separated array of colors.

local colors
colors = "red,silver,blue,orange"

In this case, toggling blue removes blue from the list:

arraytoggle colors,"blue",","
    ☞ red,silver,orange

Toggling blue again adds blue to the end of the list:

arraytoggle colors,"blue",","
    ☞ red,silver,orange,blue

This can be repeated over and over again.


See Also


History

VersionStatusNotes
10.0No ChangeCarried over from Panorama 6.0.