Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space WDESIGNER and version 24.0

Arrays can be used to store multiple pieces of information. Refer to Available Base Types for more information on arrays in Designer context in general.

Info

Multiexcerpt include
SpaceWithExcerptINTERNAL
MultiExcerptNamearrays_of_arrays
PageWithExcerptINTERNAL:_designer_excerpts_asl

The following operations can be used to manipulate and access arrays:

OperationDescription
[ ]The bracket operator can be used to get and set array elements.
append Append elements to arrays.
apply Apply an action script operations to array elements.
buildMap()Build a map from an array.
concatArrays()Concatenate the elements of one or more arrays to a target array.
count()Count the number of elements in an array.
getMapEntries()Get all map entries to an array.
join()Concatenate all strings of an array of strings, and separate them by a separator.
reduce Reduce array valued types to scalars.
select Filter array items by evaluating a boolean expression for each array element using an SQL like syntax.
sort Sort array elements in defined order.
Tip

All Any type operations listed on Any Type Operations also apply to arrays as all types derive from Any.

Creating Arrays

Multiexcerpt include
SpaceWithExcerptINTERNAL
MultiExcerptNamecreating_arrays
PageWithExcerptINTERNAL:_designer_excerpts_asl
shouldDisplayInlineCommentsInIncludesfalse

Some Array How-tos

Find below a list of some useful code snippets in array context:

TaskCode SnippetDescriptions
empty array
Code Block
set array = select each from array where false;

A new array is created containing all references to elements of array that correspond to the condition (which are none). The reference of array is changed to point to the new array.

array is empty now. You can append items using the append statement.

Code Block
set array = NULL;

The reference of array is changed to point to nowhere.

This results in a non-existent array. You can append items using the append statement, the array will implicitly be created, then.

copy all content from array1 to array2
Code Block
set array2 = select each from array1 where true;

A new array is created containing all references to elements of array1 that correspond to the condition (which are all). The reference array2 is changed to point to the new array.

In the UML model you will now see two arrays array1 and array2 that contain the same element references. A change to array1 itself will not change array2 (e.g. appending elements), but a change to an element of array1 will change that very same element in array2.

Code Block
set array2 = array1.copy();

A new array is created that contains a true deep copy of all elements of array1. The reference array2 is changed to point to the new array.

In the UML model you will now see two arrays array1 and array2 that are completely independent. A change to array1 in any way will not change array2.

append all content from array1 to array2
Code Block
set array2 = array2.concatArrays(array1)

A new array is created containing all references to elements ofarray1 and array2. The reference array2 is changed to point to the new array.

In the UML model you will now see an array array2 containing all element references of array1 and array2. A change to array1 itself will not change array2 (e.g. appending elements), but a change to an element of array1 will change that very same element in array2.