$(array)
Description
This built-in function provides various capabilities regarding array (ie. a list of things). Note that in Nexial
there really isn’t a prescriptive way of defining an array. It is simply a string, or a contiguous character,
separated by delimiter that is defined via thenexial.textDelim predefined variable. For example,
_01.png)
The above script defines an array of 6 elements (icon, picture, diagram, chart, screen, and image), and
this array is referenced by a variable named array1.
_02.png)
The above script defines an array of 2 elements ( Smith, John and Appleseed, Johnny) - the delimiter defined on
the first row is the pipe character (|), not comma. As pipe character (|) is separator for built-in function
parameters, we have to escape pipe character for array. As you can show in above image, array1 has value
Smith, John\|Appleseed, Johnny with pipe character escaped.
By default, nexial.textDelim has the value of a comma (,).
Available Functions
$(array|append|input|item)
Add an element (item) to the beginning of the target array (input), and then render the resulting array.
Example
Script
_03.png)
Output
_04.png)
$(array|ascending|input)
Renders the target array (input) in ascending order. The order is determined lexicographically via the ASCII values
of the array elements.
Example
Script
_05.png)
Output
_06.png)
$(array|descending|input)
Renders the target array (input) in descending order. The order is determined lexicographically via the ASCII values
of the array elements.
Example
Script
_07.png)
Output
_08.png)
$(array|distinct|input)
Renders the target array (input) by removing duplicated elements.
Example
Script
_09.png)
Output
_10.png)
$(array|index|input|item)
Renders the position within the target array (input) where the first occurrence of a specified element (item) is
found. For example, $(array|index|Apple,Orange,Banana|Orange) would return 1.
Note that Nexial is zero-based.
Example
Script
_11.png)
Output
_12.png)
$(array|insert|input|index|item)
Add an element (item) into the target array (input), at the specified position (index), and then render the
resulting array.
Example
Script
_13.png)
Output
_14.png)
$(array|item|input|index)
Renders the element (item) of the specified position (index, zero-based) in the target array (input).
For example, $(array|item|Salt,Pepper,Sugar,Cheese|3) would render Cheese.
Example
Script
_15.png)
Output
_16.png)
$(array|length|input)
Renders the length of the target array (input). An empty array would render 0.
Example
Script
_17.png)
Output
_18.png)
$(array|pack|input)
Remove all empty or null items in the array.
Example
Script
_27.png)
Output
_28.png)
$(array|prepend|input|item)
Add an element (item) to the end of the target array (input), and then render the resulting array.
Example
Script
_19.png)
Output
_20.png)
$(array|remove|input|index)
Remove an element (item) from the array (input), at the specified position (index), and then render the
resulting array.
Example
Script
_21.png)
Output
_22.png)
$(array|replica|input|count)
Transform the current array to multiple copies of itself (append the array to itself). The
count is used to specify the number of times to repeat. For example, $(array|replica|a,b,c|2) would yield a
array of a,b,c,a,b,c.
Example
Script
_29.png)
Output
_30.png)
$(array|replicaUntil|input|size)
Transform the current array to multiple copies of itself (append the array to itself),
until the length of the array is the same as size. For example, $(array|replicaUntil|a,b,c|7) would yield
a list of a,b,c,a,b,c,a.
Example
Script
_31.png)
Output
_32.png)
$(array|reverse|input)
Renders the array (input) in its reversed order.
Example
Script
_23.png)
Output
_24.png)
$(array|subarray|input|start|end)
Renders a portion of the target array (input), based on the specified start and end positions. One may specify
end as -1 to signify the last position of the target array.
Example
Script
_25.png)
Output
_26.png)