Dynamic Texts

  • General
  • Overview

Append

Create

Get

Converter

Length

Mid

Switch

Set[i]

Memory Diagnosis

Find

Load Text Resource

Comparator

Visualization

Overview

The data type “Dynamic Text” allows the memory efficient processing of texts with a length of up to 4095 characters. Only the needed memory is allocated for every single text. In difference to the string data types with a fixed size a combination of short and long texts does not lead to a large amount of wasted memory. At present the “Dynamic Texts” are only stored in the RAM, i.e. they are only available during runtime. With the functions blocks of this library, the “Dynamic Texts” are created by the conversion of standard texts and numeric values or the loading of HMI resource texts. Furthermore the function blocks support the processing and the display of the texts.

The memory blocks DYNTEXTDATA and DYNTEXTRAM form the base of the data type “Dynamic Text”. The elements of the first memory block are assigned to the outputs and the internal memories of the function blocks. They contain references to sections of the second memory block. The texts are stored in these sections. The offset and the size in bytes serve as reference information. They are displayed during the online observation in the signal line window.

Some distinctive features in comparison to the standard data types result from the described reference structure. So multiple elements of DYNTEXTDATA can refer to the same section of DYNTEXTRAM. And for the assignment of a longer text a new memory allocation is necessary, i.e. a new section must be found that fits for the size of the new text. In that case the values of offset and size are adapted in the belonging DYNTEXTDATA element.

If the used section cannot be enlarged anymore and a new section was assigned, then DYNTEXTRAM gets fragmented, i.e. a gap occurs between two used sections. The gap will be checked, if it can be used for one of the following memory allocations. However it is not probable, that the needed memory amount exactly corresponds to the gap size. Therefore the additional memory consumption for the fragmentation must be taken into account when the size of DYNTEXTRAM is defined in the resource request file.

The function block "Memory Diagnosis" is used to supervise the fragmentation. It provides LONG values with the size of DYNTEXTRAM in bytes on its outputs as well as the amount of the used memory and the number of gaps. If a HIGH signal is connected with the BIT input, the defragmentation (garbage collection) starts. And the used sections will be moved one after another so that no gaps will remain anymore. The references in DYNTEXTDATA will be adapted accordingly. The runtime cost of the defragmentation depends on the number of the DYNTEXTDATA elements and the size of the sections that have to be moved. This should be kept in mind when implementing an automatic defragmentation strategy.

If a memory allocation fails, i.e. no free section with the needed size could be found, the offset and the size of the DYNTEXTDATA element are initialized with 0. The following operations and function block interpret this reference as an empty text and process it accordingly.