Skip to main content

Displaying a text dynamically

You can define a text in Texts → Text in order to display it statically. A text in Texts → Tooltip is shown as a tooltip. You can configure the text in such a way that the contents of a variable are displayed with it.

You can expand a static text by exactly one placeholder with a formatting specification in order to display the contents of a variable at this location at runtime. The variable which you have assigned in the Text variable property is displayed. When the variable changes in the application code, its display in the visualization changes at the same time.

Requirement: A project with a visualization is open.

  1. Open the visualization and add a Text Field element.

    The Properties view shows the configuration of the element.

  2. Configure the Texts → Text property with File name: %s.

    The text contains the %s placeholder.

  3. In the application in the PLC_PRG POU, declare a type-compliant variable strFileName : STRING := 'File_A';

  4. Configure the Text variable property of the button with PLC_PRG.strFileName.

    The contents of the variable will be displayed instead of the placeholder at runtime.

  5. Compile, download, and start the application.

    The application runs. The visualization opens. The element displays the text: File name: File_A

A text entered in the Texts → Text or Texts → Tooltip visualization property is automatically entered in GlobalTextList under POUs. There you can translate the text into other languages.

For further information see: Using static text in GlobalTextList