Array Actions
Append an item to an array.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array |
item* | text, expression, variable | the item to append |
Example
myArray = createArray() appendArrayItem(myArray,"banana") # Should return 1 log(myArray.length)
Append an array to an array.
Property | Value | Description |
---|---|---|
destArray* | expression, variable | the array to append to |
srcArray* | expression, variable | the array to append |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear"]) # Should return 3 log(myArray.length)
Check if an array contains a value.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array |
value* | text, expression, variable | the value to match |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
myArray = createArray() appendArrayItem(myArray,"banana") # Should return true hasBanana = arrayContains(myArray, "banana") # Should return false hasApple = arrayContains(myArray, "apple")
Make a copy of an array.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array to copy |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear"]) newArray = copyArray(myArray) # Should return "banana" log(newArray[1]) myArray = createArray(10) # Should return 10 log(myArray.length)
Create an array.
Property | Value | Description |
---|---|---|
size | expression, variable | initial size of the array - (default: 0) |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
myArray = createArray(10) # Should return 10 log(myArray.length)
Get an array item.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array |
index* | expression, variable | the index of the item to get |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear"]) myItem = getArrayItem(myArray,1) # Should return "banana" log(myItem)
Get the size of an array.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear"]) numItems = getArraySize(myArray) # Should return 3 log(numItems)
Insert an array item.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array |
index* | expression, variable | the index in the array to insert the item |
item* | text, expression, variable | the item |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear"]) insertArrayItem(myArray,2,"plum") # Should return "apple,banana,plum,pear" log(myArray)
Insert items from one array into another array.
Property | Value | Description |
---|---|---|
destArray* | expression, variable | the array to insert into |
index* | expression, variable | the index in destArray to insert the srcArray |
srcArray* | expression, variable | the array to insert |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear"]) insertArrayItems(myArray,1,["orange","grapes"]) # Should return "apple,orange,grapes,banana,pear" log(myArray)
Join the values of the items in an array into a string.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array |
delimiter | text, expression, variable | the delimeter to inject in between the items in the string (default: none) |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear"]) myString = joinArray(myArray,"::") # Should return "apple::banana::pear" log(myString)
Remove and return an item from an array.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array |
index* | expression, variable | the index of the item to remove |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear"]) removedItem = removeArrayItem(myArray,1) # Should return "apple,pear" log(myArray) # Should return "banana" log(removedItem)
Remove and return items from an array.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array |
index* | expression, variable | the starting index of the items to remove |
count* | expression, variable | the number of items to remove |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear","grapes","coconut"]) removedItems = removeArrayItems(myArray,1,2) # Should return "apple,grapes,coconut" log(myArray) # Should return "banana,pear" log(removedItems)
Remove and return the last item from an array.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array to remove the last item from |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear","grapes","coconut"]) removedItem = removeLastArrayItem(myArray) # Should return "apple,banana,pear,grapes" log(myArray) # Should return "coconut" log(removedItem)
Reverse the order of the items in an array.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array to reverse |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear","grapes"]) reverseArray(myArray) # Should return "grapes,pear,banana,apple" log(myArray)
Set array item.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array |
index* | expression, variable | the index of the item to set |
item* | text, expression, variable | the item |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear"]) setArrayItem(myArray,2,"plum") # Should return "apple,banana,plum" log(myArray)
Set the size of an array.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array |
size* | expression, variable | the new size |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear"]) setArraySize(myArray,1) # Should return "apple" log(myArray)
Create a new array from a subset of the items in an array.
Property | Value | Description |
---|---|---|
array* | expression, variable | the original array |
index* | expression, variable | the starting index of the items to be put in the new array |
count* | expression, variable | the number of items to put into the new array |
returnVariable | expression, variable | name of the variable to be assigned to the return value |
Example
myArray = createArray() appendArrayItems(myArray,["apple","banana","pear","grapes"]) newArray = sliceArray(myArray,0,2) # Should return "apple,banana,pear,grapes" log(myArray) # Should return "apple,banana" log(newArray)
Sort an array.
Property | Value | Description |
---|---|---|
array* | expression, variable | the array to sort |
ignoreCase | boolean, expression, variable | ignore case when comparing items (default: false) |
descending | boolean, expression, variable | sort in descending order (default: false) |
keyFields | text, expression, variable | comma separated list of fields or properties to sort on (default: sort based on the string value of each item) |
Example
myArray = createArray() appendArrayItems(myArray,["apple","pear","grapes","banana"]) sortArray(myArray) # Should return "apple,banana,grapes,pear" log(myArray)