Array ArrayToString Compact Count First GetAt IndexOf Join |
Last Map Middle Point2D Point3D RemoveArrayValue RemoveMapValue |
Reverse SetArrayValue SetMapValue Sort Uniq Yield YieldMap |
Array | |
---|---|
Creates a new array from a specified list of values | |
Syntax | Array (value1, value2, ...) |
Inputs | Value1, value2, ... are the items you wish to place in the array, they can be of any type |
Notes | See also Tutorial on Arrays |
Examples | Array (5, "text", 10deg, 64mm) = [5,text,10deg,64mm] |
See Also | RemoveArrayValue |
ArrayToString | |
---|---|
Converts an array into a string, using a specified separator (optional) | |
Syntax | ArrayToString (array, separator) |
Inputs | Array is what you want converted to a string. The separator string is optional, the default is the pipe character '|' |
Outputs | ArrayToString takes each element in array and adds them to a string, one after another. In between each of the elements, it inserts separator |
Notes | The default separator (the pipe character) is useful for Friendly Page drop-down lists, because this the format the "Combo Source" field uses. Note that separator can be a full string, not just a single character |
Examples | ArrayToString ([5, "text", 10deg, 64mm]) = "5|text|10deg|64mm" ArrayToString (["item1", "item2", "item3"], " AND ") = "item1 AND item2 AND item3" |
See Also | StringToArray |
Compact | |
---|---|
Removes all occurrences of a specified value from an array | |
Syntax | Compact (array, val) |
Inputs | Array is what any occurrences of val will be removed from. Val is optional, the default is the Empty element |
Notes | If val is omitted, any empty elements (such as zero or blank strings) will be removed |
Examples | Compact ([4, "", 80mm, $6.30, 0.0 radians]) = [4, 80mm, $6.30] Compact ([50mm, 3" - 2", 3.3cm, 25.4mm], 1") = [50mm, 33mm] |
See Also | Uniq |
Count | |
---|---|
Returns the number of elements in the specified array | |
Syntax | Count (array) |
Inputs | Array is what you want to find the size of |
Examples | Count (["item1", "item2", "item3"]) = 3 Count (10) = 1 |
First | |
---|---|
Returns the first element or elements from the specified array | |
Syntax | First (array, count) |
Inputs | Array is what you want the first element(s) of. Count is optional, and is the number of elements you want (default = 1) |
Outputs | Returns the first count elements of array as another array |
Notes | If count is more than the number of elements in array, the whole array will be returned |
Examples | First (["item1", "item2", "item3"]) = [item1] First (["item1", "item2", "item3"], 2) = [item1,item2] |
See Also | Last, Middle |
GetAt | |
---|---|
Returns a single specific element from an array | |
Syntax | GetAt (array, index) or GetAt (map, key) |
Inputs | Array or Map is what you want the element returned from, and Index or Key is the position of the element |
Notes | This is effectively the same as saying array [ index ]. The index of the first item is one, not zero. NB: Accepts map and key as well as array index |
Examples | GetAt ([5, "text", 10deg, 64mm], 3) = 10deg |
IndexOf | |
---|---|
Find the first instance of item in array | |
Syntax | IndexOf (item, array [,start]) |
Inputs | IndexOf finds the first instance of item in array. Optionally you can find first instance from Start position |
Notes | The index numbers in an array start from 1, as opposed to zero as in some programming languages (C, Java, etc). This means that the first item in an array has an index of 1, the second has index 2 and so on. Search items are case independent. See also Tutorial on Arrays |
Join | |
---|---|
Concatenates two or more specified arrays | |
Syntax | Join (array1, array2, ...) |
Inputs | Array1, array2, ... are the arrays you wish to join together |
Outputs | A new array containing all the elements of the original arrays is returned |
Notes | The elements are placed in the new array in the order that the original arrays were given |
Examples | Join ([34, 6, 93.5], [4.5sqm, 1.7rad], ["text"]) = [34, 6, 93.5, 4.5sqm, 1.7rad, "text"] |
Last | |
---|---|
Returns the last element or elements from the specified array | |
Syntax | Last (array, count) |
Inputs | Array is what you want the last element(s) of. Count is optional, and is the number of elements you want (default = 1) |
Outputs | Returns the last count elements of array as another array |
Notes | If count is more than the number of elements in array, the whole array will be returned |
Examples | Last (["item1", "item2", "item3"]) = [item3] Last (["item1", "item2", "item3"], 2) = [item2,item3] |
See Also | First, Middle |
Map | |
---|---|
Creates a new map from a specified list of key:value pairs | |
Syntax | Map {key:value ,key2:value2, ... } |
Inputs | Key is a string and Value are the items you wish to find in the map, they can be of any type. |
Notes | This is a Map so that a lot of the existing square bracket-style properties from the libraries can be collapsed. The formula syntax is: [ : , : ... ] where both key and value can be any valid literal data value. |
Examples | See tutorial on Maps |
See Also | RemoveMapValue |
Middle | |
---|---|
Returns a set of elements from the specified array | |
Syntax | Middle (array, start, count) |
Inputs | Array is what you want to get the elements from. Start is the index of the first element you want, and count and is the number of elements to be returned |
Outputs | Returns count elements of array as another array, beginning from element start |
Notes | Count is an optional parameter - if it is not provided, Middle returns all the elements from start to the end of array |
Examples | Middle (["item1", "item2", "item3", "item4"], 3) = [item3,item4] Middle (["item1", "item2", "item3", "item4"], 2, 1) = [item2] |
See Also | First, Last |
Point2D | |
---|---|
A pair of lengths, in brackets, comma separated, representing a point in the xy plane | |
Syntax | Point2D (valx, valy) |
Inputs | valX is a length which is the x-coordinate of the point. valY is a length which is the y-coordinate of the point |
Notes | An array of Point2D values can also be defined by using the shorthand syntax: Point2D([[1,2],[3,4],[5,6]]) which is equivalent to [Point2D(1,2), etc] |
Examples | Point2D(3mm,4mm) |
Point3D | |
---|---|
Lengths, in brackets, comma separated, representing a point in the xyz plane | |
Syntax | Point3D (valx, valy, valz) |
Inputs | valX is a length which is the x-coordinate of the point. valY is a length which is the y-coordinate of the point. valZ is a length which is the z-coordinate of the point. |
Examples | Point3D(3mm,4mm,5mm) |
RemoveArrayValue | |
---|---|
Removes value of specified array | |
Syntax | RemoveArrayValue (array, index) |
Inputs | Array is what you wish to remove the elements of. Index specifies the index to remove. |
RemoveMapValue | |
---|---|
Removes value of specified map | |
Syntax | RemoveMapValue (map, key) |
Inputs | Map is what you wish to remove the elements of. Index specifies the key:value pair to remove. |
Reverse | |
---|---|
Returns an array which is in the reverse order of the specified array | |
Syntax | Reverse (array) |
Inputs | Array is what you wish to reverse the elements of |
Examples | Reverse ([5, "text", 10deg, 64mm]) = [64mm, 10deg, "text", 5] |
SetArrayValue | |
---|---|
Set the value for specified key in the array | |
Syntax | SetArrayValue (array, key, newValue) |
Inputs | Array is what you wish to set the item into Key is the key whose value needs to be updated within this array value that you want set in array |
Notes | Must provide array name as string, can be qualified as context.name. If the string passed in as the first parameter to these functions is the name of a local variable, update the local variable rather than doing a context lookup. |
Examples | If we have an array ABC containing ["A","B","C"] then the action command SetArrayValue(ABC,2,"NewValue") changes ABC to ["A","NewValue","C"] |
SetMapValue | |
---|---|
Set the value for specified key in the map | |
Syntax | SetMapValue (map, key, newValue) |
Inputs | Map is the map to be updated Key is the key whose value needs to be updated within this map NewValue is the new value to be put into the map at this key |
Notes | Must provide map name as string, can be qualified as context.name. If the string passed in as the first parameter to these functions is the name of a local variable, update the local variable rather than doing a context lookup. The new value can be any type, including another map or an array. |
Examples | If we have a map ABC containing {"key1":3mm, "anotherkey":"somevalue"} then the action command SETMAPVALUE(ABC,"key1",Yes) changes ABC to {"key1":Yes, "anotherkey":"somevalue"} |
Sort | |
---|---|
Returns a copy of the specifed array with the elements sorted | |
Syntax | Sort (array) |
Inputs | Array is what you want to sort the elements of |
Notes | Sorting an array that contains different data types can return unexpected results |
Examples | Sort ([43, 6.4, 983, -13]) = [-13, 6.4, 43, 983] Sort ([5, "text", 10deg, 64mm]) = ["text", 5, 64mm, 10deg] |
Uniq | |
---|---|
Returns a copy of the specified array with all the adjacent duplicate elements removed | |
Syntax | Uniq (array) |
Inputs | Array is what you want all the adjacent duplicates removed from |
Notes | Uniq will only remove an element if it is identical to one next to it. To remove all duplicates from an array, use the Sort function first. Different units of the same type will be converted to a single unit before being compared. eg Uniq ([25.4mm, 1 inch]) will convert the "1 inch" to "25.4mm", then remove it because it matches another element |
Examples | Uniq([8, 4, 3, 4]) = [8, 4, 3] Uniq([180deg, PI rad, 35mm]) = [180deg, 35mm] |
See Also | Sort |
Yield | |
---|---|
Use in a ForEach loop to generate all the elements of an array. | |
Syntax | [ (for loop on var) {yield expression using var} ] |
Inputs | var and an {expression} using var. The outer square brackets define an array generated by the { yield expression } for each value of var in the for-loop. |
Examples | [ for each x in [3,5] { yield x*2 } ] generates the array [6, 8, 10] In this example, the expression x*2 is evaluated once for each value of the for-loop control variable, ie 3,4,5 then the resulting elements are put into an array. |
See Also | Loops |
YieldMap | |
---|---|
Use in a foreach loop to generate all the elements of a map. | |
Syntax | [ (for loop on key:val map) {yieldmap key : expression using value} ] |
Inputs | key:val and an {expression} using val. The outer square brackets define a map generated by the { yieldmap key:expression } for each key:val of the input map in the for-loop. |
Examples | [ for each key,val in [3:5,4:6] { yieldmap key:val*2 } ] generates the map [3:10, 4:12] In this example, the expression val*2 is evaluated once for each key,val of the for-loop, i.e. 3:5 then 4:6 then the resulting key:value elements are put into a map. |
See Also | Loops |