Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This section describes functions that are used to manage lists and their elements. Lists can be created to hold any type of data.

listAdd

Adds a new element to the end of an existing list.

...

Info
titleExample - Using listAdd

The following code leaves a list consisting of the two elements 7 and 5.

Code Block
list <int> myIntList = listCreate(int, 7); 
 listAdd(myIntList, 5);


listClear

Removes all elements from a list.

...

ParameterDescription

list

The list of elements to be removed

Returns

Nothing

listCreate

Creates a list of any type, and (optionally) populates it.

...

ParameterDescription

type

The type of the elements comprising the list

element<n>

The value of an element to be added to the list. Optional parameters: if none is entered, the list will be empty.

Returns

The list

listCreateSync

Creates a synchronized list of any type, and (optionally) populates it. This function may be useful for global lists in real time workflows, where the same list may be accessed from several threads at the same time.

...

ParameterDescription

type

The type of the elements comprising the list

element<n>

The value of an element to be added to the list. Optional parameters: if none is entered, the list will be empty.

Returns

The list

listFindIndex

Calculates the index of a requested list element.
The condition is tried for each element in the list until there is a match or the end of the list is reached.

...

Info
titleExample - Using listFindIndex

A list of integers containing the following elements [50, 2, 4, 152, 4] is searched for an element equal to 4:

Code Block
debug( listFindIndex( myList, i, i == 4 ) );

The output is 2, since it is the index number of the first element equal to 4 in the list.

listGet

Retrieves an element from a given position in the list.

...

ParameterDescription

list

A list

index

Index of the element to retrieve

Returns

The value given at the defined index

listInsert

Inserts a value on a given position in a list. Note that this will NOT overwrite any existing values on the position, but only move the old element up a position.

...

Info
titleExample - Using listInsert

A list consists of the following elements: [2, 5, 72, 19] and the new value 127 is to be inserted on index position 2. This means the new indexes for the elements containing 72 and 19 are now 3 and 4 respectively:

Code Block
listInsert( mylist, 2, 127);

myList now looks like this: [2, 5, 127, 72, 19]

listRemove

Removes an element from a list.

...

ParameterDescription

list

A list

index

Index of the value to remove. The index must be in the range 0<=index<listSize ( list ) or the workflow will abort with a runtime error.

Returns

Nothing

listSet

Replaces an existing element in a list.

...

Info
titleExample - Using listSet

A list consists of the following elements: [2, 5, 72, 19] and the new value 127 should replace the value of the element on index position 2:

Code Block
listSet( mylist, 2, 127);

myList now looks like this: [2, 5, 127, 19]

listSize

Gets the size of a list.

Code Block
int listSize ( list<type> list)

...

ParameterDescription

list

A list

Returns

The number of elements in the list

listSort

Sorts a list of any type. For UDR lists, sorting is based on a field in the UDR.

...