iterate(Vector,...)
function with more powerful capabilities.
This function allows you to generate a vector by elements of another vector, array, or enumeration.
The function iterates by the source's elements and for each of them executes
a subquery specified in the subquery
parameter.
The object returned by the subquery is added to the new vector.
The subquery receives the original element in the predefined
_element
variable accessible within it.
Effectively, this function would be the same as the following block:
v = Vector();
i = fromIndex;
while (i < toIndex && i < source.size())
{
_element = source.elementAt(i);
newElement =
// the subquery operators generating
// a new element from _element variable
v.addElement(newElement);
i = i + 1;
}
return v;
source
subquery
_element
variable.
The subquery should be prepared using FlexQuery() function (see example below).
fromIndex
toIndex
Note: If the source
parameter is null
,
the function will return an empty vector.
FlexQuery(), iterate()
The following script converts a sequence number like "1.2.5.9"
(which initially is simply a string) into a vector of its subnumbers
having the Number
type:
s = getAttrStringValue ("sequenceNumber");
v = breakString(s, ".");
generateVector (v, FlexQuery(toNumber(_element)))