Displaying a text dynamically
You can define a text in
in order to display it statically. A text in 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
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.
Open the visualization and add a Text Field element.
The Properties view shows the configuration of the element.
Configure the
property withFile name: %s
.The text contains the
%s
placeholder.In the application in the
PLC_PRG
POU, declare a type-compliant variablestrFileName : STRING := 'File_A';
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.
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