Skip to main content

Printing a dynamic text using a variable

Besides the automatically created global text list, there are also custom text lists.

If an element should dynamically display multiple texts one after the other, then a string variable is specified for it, not the text ID itself. The variable is then set programmatically (in IEC code) to change the text IDs. In this way, a dynamic text display in the visualization element is achieved.

In custom text lists, you can translate the default texts and add more languages when needed. If language switching is implemented for visualizations, then the translation is displayed at runtime for the configured text.

. Elements which can dynamically display the text referenced under the Dynamic texts property:
Example 1. Example
  1. All texts about a topic (such as error handling) are listed in a text list.

    _vsprt_ui_example_tl_errorhandling.png
  2. The Text Field visualization element is configured for dynamic display:

    1. The strErrorHandling variable is entered in the Dynamic texts element property under Text list.

    2. The strHandlingID variable is entered in the Dynamic texts element property under Text index.

  3. A case distinction is implemented in the application code where the text for error handling is displayed depending on the error.

    For this purpose, a text ID from the ErrorHandling text list is assigned to the strHandlingID variable depending on the iError error.

    // Text list name
    strErrorHandling := 'ErrorHandling';
    //Assigning text ID
    CASE iError OF  
        2: strHandlingID := 'ID_2';
        3: strHandlingID := 'ID_3';
        4: strHandlingID := 'ID_3';
    ELSE	strHandlingID := 'ID_1';	
    END_CASE;