To access a value in an indexed field (array), use the following syntax:
dataset_reference.indexed_field_name[index]
The indexed_field_name parameter defines the field name in the dataset. Index is an integer that addresses an indexed element in the array.
To specify the indexed_field_name string with the bracket notation, use the following syntax. In the example, indexed_field_name_expression is a CA Process Automation expression that returns the indexed_field_name string.
dataset_reference[indexed_field_name_expression][index]
Like JavaScript arrays, CA Process Automation indexed fields are arrays of arrays instead of true arrays. To access an element in an array of arrays, use the [ ] operator twice. For example, for the two-dimensional indexed integer-field named integers, every list element integers[x] is itself an indexed list of integers. To access a specific integer in the indexed field, you would write the expression integers[x][y]. In general, for any indexed field of n-dimensions, you use the following syntax to access any data element:
dataset_reference.indexed_field_name[index1][index2] ... [indexn]
The index parameter is an integer or an expression that returns an integer. The parameter has a value from 0 (for the first value in an indexed list) to the length of the list minus 1. Evaluation of the index is circular, so when the index value exceeds the length of an indexed list, the following formula determines its value:
Actual-index = index % length-of-the-list;
In other words, for n elements in an indexed field, you get the following results:
The following table illustrates the results of accessing elements of an indexed field in a process dataset:
|
Expression |
Description |
|---|---|
|
value = Process.X[2] |
Refers to the third element of an indexed field X of the process dataset. |
|
value = Process.X[18] |
For an indexed field X with a size of 19, this expression refers to element 19 of X, the same as Process.X[18]. |
|
value = Process.X[Process.Y + 2] |
An expression calculates the index. |
|
value = Process.A[5][2] |
Returns the value in a two-dimensional array. The third element in the sixth indexed list that the array defines addresses the array. |
|
Copyright © 2013 CA.
All rights reserved.
|
|