Table of Contents

ListDint

Namespace
ZCore
Extends
Inherited Methods
FUNCTION_BLOCK ListDint EXTENDS ZCore.List

This function block specialized List for the type DINT. The main business logic of the list is implemented by List and this function block only is (mostly) used to hold the actual data that is stored by the list. This function block can be used as a template for other kind of datatypes.

Constructor

FB_init

METHOD FB_init (
 [input] bInitRetains : BOOL,
 [input] bInCopyCode : BOOL,
 [input] bufferSize : DINT,
 [input] logicBuffer : POINTER TO DINT,
 [input] dataBuffer : POINTER TO DINT)

The constructs is used to set up the logic buffer the the list, the List has to be initalized as shown in the example below, i.e. the zeroth index of the array that is passed to the function block has to be indexable.

logicBuffer_ : ARRAY[0..100] OF DINT;
dataBuffer_ : ARRAY[0..100] OF DINT;
list_ : ListDint(100, ADR(logicBuffer_), ADR(dataBuffer_));

Inputs

bInitRetains BOOL

if TRUE, the retain variables are initialized (warm start / cold start)

bInCopyCode BOOL

if TRUE, the instance afterwards gets moved into the copy code (online change)

bufferSize DINT := 0
logicBuffer POINTER TO DINT

must be an array in the form ARRAY[0..#Items]

dataBuffer POINTER TO DINT

must be an array in the form ARRAY[0..#Items]

Methods

Append

METHOD Append (
 [input] value : DINT) : DINT

This method appends an actual instance of value into the databuffer at the currently last position in the list. Internally AppendIndex is used.

The method returns the actual index of the data buffer that was used for this operation and -1 if there was no space to add the item to the list.

Inputs

value DINT

Returns

DINT

FindFirstIndexOf

METHOD FindFirstIndexOf (
 [input] val : DINT) : DINT

This method iterates through the list and finds the first occurance of val in the databuffer. Naturally, this method considers the ordering of the instances according the the logic buffer of the list.

The method return -1 if no such value is found.

Inputs

val DINT

Returns

DINT

InsertAt

METHOD InsertAt (
 [input] idx : DINT,
 [input] value : DINT) : DINT

This method inserts an actual instance of value into the databuffer at index=idx, where the first item of the list is indexed by 0. Internally List.AddIndex is used.

The method returns the actual index of the data buffer that was used for this operation and -1 if there was no space to insert the item into the list.

Inputs

idx DINT

starting from idx=0 for the first element

value DINT

Returns

DINT

ItemAt

METHOD ItemAt (
 [input] idx : DINT) : DINT

This method returns the value of the data buffer instance at index=idx. Naturally, idx refers to the actual ordering in the list via the logic buffer and the first item of the list is referred to by idx=0.

Inputs

idx DINT

starting from idx=0 for the first element

Returns

DINT

Remove

METHOD Remove (
 [input] val : DINT)

This method removes the first occurence to val from the list.

Inputs

val DINT