FB_BA_StaticArray

The function block is an extension of the function block FB_BA_DynamicArray.
The aim of this extension is to avoid using router memory and use static memory instead. This is declared in the application, where its size can be flexibly adjusted.
![]() | The static memory must be provided by the application, but it must never be changed outside of the array! The management should take place in all cases via the array itself. |
Using a static array is recommended when the expected memory requirements can be reliably estimated.
For efficiency reasons, the memory area should be sized so that only as much memory as necessary is reserved. Global constants and parameter lists are suitable for defining memory limits.
Inherits from: FB_BA_DynamicArray
Application
The use cases are essentially the same as those for dynamic arrays. There are only minor differences in the declaration, since the external memory area and its size must be passed as parameters.
Further information
See examples of initialization during variable declaration.
Examples
Example declaration of the array, its static memory, and corresponding constants.
VAR_GLOBAL CONSTANT
uiObjectCount : UINT := 100;
uiArrayMemSize : UINT := TO_UINT(uiObjectCount * SIZEOF(FB_OBJECT));
END_VARVAR
bArrayMemory : ARRAY[0.. uiArrayMemSize] OF BYTE;
fbArray : FB_StaticArray := (uiEntrySize:=SIZEOF(FB_Object), pExtMemory:=ADR(bArrayMemory), uiExtMemorySize:=uiArrayMemSize);)
END_VARFurther information
Since the static array is to be used in exactly the same way as the Dynamic array, appropriate application examples are documented there.
Methods
Name | Definition location | Description |
|---|---|---|
Local | Creates a new data set at the end of the array and copies the content of the specified entry to the internal memory. | |
Local | Resets the complete content of the array. | |
Local | Creates a new data set at the end of the array and copies the content of the specified entry to the internal memory. | |
Determines the position of the specified entry in the array by comparing its content with the data sets of the array. | ||
Copies the contents of the data set to a certain position in the specified memory area. | ||
Determines a pointer to the internal memory of the specified data set. | ||
Removes the data set at the specified index position from the array. | ||
Determines the position of the specified entry and deletes it from the array. | ||
Resets the complete content of the array. | ||
Replaces the existing data set with a new one by overwriting the internal memory area of the existing data set with the value of the new entry. | ||
Creates a new entry at the end of the array and copies its memory address (i.e., the address to which the pointer pEntry points) to the internal memory. | ||
Determines the position of an entry in the array by comparing its address with the addresses stored in the array. | ||
Outputs a pointer to the memory address of the requested entry. | ||
Determines the position of the specified entry and deletes it from the array. | ||
Replaces an existing entry with a new one. |
