Using Texts¶
You can get displayed text in an element by assigning a string in the element property GlobalTextList in view POUs and they cannot be modified during runtime, neither programmatically nor via an user input.
. For example all base elements have this property. Also, you can get displayed a text as a tooltip (element property ). Texts assigned in this way are static. They are managed in the objectHowever, you can extend a static text by (exactly) 1 placeholder containing a formatting specification, in order to output the content of a variable at this place. At runtime the current value of the variable, which you have assigned to the element via property
, will be output.Note
On the possible formatting specifications please see: Placeholders with Format Definition in the Output Text
By dynamic configuration you can animate the optical representation of the text.
You can localize the static texts, if you have set up multilingualism in your project.
See some examples for the text configuration of visualization elements in the following chapters.
See also
Labeling an image element with a static text
Below the Application object insert an object Image Pool named
ImagePool_A
.In the image pool
ImagePool_A
add your stop symbol image file with IDStop
.- ⇒
Open the visualization and from the ToolBox draw an element Image into the editor.
- ⇒
The input assistant opens. In tab
Category
you see the image poolImagePool_A
.
Select the image
Stop
and close the dialog with OK.Configure the property Text of the image:
ImagePool_A, Stop
Configure the property
:Left
.Configure the property
:Bottom
.- ⇒
Text output: Element outputs the result of ST code which is executed on a mouse-click
Open the visualization and insert a Button element.
- ⇒
The Properties view opens for the new element.
Configure property Text:
Number of clicks: %I
- ⇒
The string contains the placeholder
%I
.
In POU
PLC_PRG
of the application declare a type-conform variable:iClicks : INT;
Configure the property Text variable of the button element with
PLC_PRG.iClicks
.- ⇒
At runtime the variable value will be output instead of the placeholder.
Below property Inputconfiguration, in the cell containing the input event
OnMouseClick
, click on Configure.From the list of possible actions choose
Execute ST-Code
.Enter the code for the action in the editor Execute ST-Code:
PLC_PRG.iClicks := PLC_PRG.iClicks + 1;
Close the dialog with OK.
- ⇒
The user input is configured.
Build, download and start the application.
- ⇒
The application is running. The visualization opens. The element is labeled and the number of clicks will be output. If you as user click on the button, the number will be increased.
Text output: Dynamic output using a textlist
Using the Text field element you can produce a dynamic text output. The text output can be effected via an user input or via the application program.
Open the visualization and insert a Text field element.
- ⇒
The Properties view shows the configuration of the element.
Below the application add a Text List with the following entries:
Textlist_A
.- ⇒
In POU
PLC_PRG
of the application declare the text variable:strTextID : STRING := '0';
Also declare the variable
strTooltipID : STRING := '0';
Also declare the variable
iText : INT;
Configure the property
with'Textlist_A'
.Configure the property
withPLC_PRG.strTextID.
Configure the property
withPLC_PRG.strTooltipID.
In POU
PLC_PRG
implement the CASE instruction as shown below.- ⇒
The variables in property
are programmed.
Configure the property
forExecute ST-Code
withPLC_PRG.iText := (PLC_PRG.iText + 1) MOD 4;
- ⇒
For element Text field an user input is configured.
Build, download and start the application.
- ⇒
The application is running. The visualization opens. In the text field the text
None
is output. When you as user click on the element, the text changes toDynamic_ File_A
. And the matching tooltip is available:Information A
. With each click the text changes according to the CASE instruction.
CASE instruction
CASE iText OF
0:\ strTextID := '0';
\ strToolTipID := '0';
1:\ strTextID := '1';
\ strToolTipID := '4';
2:\ strTextID := '2';
\ strToolTipID := '5';
\
3:\ strTextID := '3';
\ strToolTipID := '6';
ELSE\
\ strTextID := '0';
\ strToolTipID := '0';
END_CASE;
Text output: Configuring a static + dynamic text output
In property
you can define a text in order to get a static text output. A text in will be displayed as tooltip. You can configure the text in a way, that the content of a variable is additionally output.You can extend a static text by (exactly) 1 placeholder including a formatting definition, in order to output the content of a variable at this place at runtime. The variable must be assigned in property
. When the variable value changes in the application code, then at the same time the output in the visualization changes.Open the visualization and insert an element Text field.
- ⇒
The Properties view shows the element configuration.
Configure the property
:File name: %s
- ⇒
The text contains the placeholder
%s
.
In POU
PLC_PRG
of the application declare a type-conform variablestrFileName : STRING := 'File_A';
Configure the property Text variable of the text field with
PLC_PRG.strFileName
.- ⇒
At runtime the variable value will be output instead of the placeholder.
Build, download and start the application.
- ⇒
The application is running. The visualization opens. The text field element displays the text:
File name: File_A
See also
Configuring text input in a text field
You can use the Text field element in order to output the text given by a variable, or to provide a place, where the user can give input on the variable.
Additionally you can configure a text input. In this case on an user input an input field in the element Text field will appear. As a precondition you must have configured an user input action in the property .
See also
Showing text as a tooltip
Open the visualization and insert an element Text field.
- ⇒
The Properties view shows the element configuration.
Configure the property
:File name: %s
- ⇒
The text contains the placeholder
%s
Configure the property
:Storage location: %s
In POU
PLC_PRG
of the application declare a type-conform variablestrFileName : STRING := 'File_A';
In POU
PLC_PRG
of the application declare also the variablestrFileDir : STRING := 'D:/Data';
Configure the property Text variable of the text field with
PLC_PRG.strFileName
.- ⇒
At runtime the variable value will be output instead of the placeholder.
Configure the property Tooltip of the text field with
PLC_PRG.strFileDir
.Build, download and start the application.
- ⇒
The application is running. The visualization opens. The text field element shows the text
File name: File_A
. When the mouse cursor is moved above the text field, the tooltip will be displayed:Storage location : D/Data
.
See also
Configuring element Text field for text input
The user should be able to enter text in a text field. For this configure an input of type Write variable on a text output variable. This text output variable will store the text input of the user and will display this text instead of the placeholder (this is %s
in the example below). You specify the text output variable in the property .
In POU
PLC_PRG
of the application declare a string variable:strInput : STRING;
Open the visualization and insert an element Text field.
- ⇒
The Properties view shows the configuration of the element.
In property
enterInput: %s
.In property Inputconfiguration for mouse action OnMouseClick click on Configure to open the Input Configuration dialog box. There choose action Write a Variable and activate option Use text output variable. Close with OK.
In the element property
assign the text output variablePLC_PRG.strInput
.Build, download and start the application.
- ⇒
The application is running. The visualization opens. The element outputs the text:
Input:
. Click in the element to open an input field, where you can enter a string. After having terminated the input byEnter
, the text will be adopted.
Animating the text display
Configure the property
in order to animate the display of a text. All base elements have this property, additionally the table, scrollbar and text field element.See also
Configuring the ‘Label’ element
Open a visualization and insert an element Label.
- ⇒
The Properties view with the pre-set property configuration opens.
Configure the property
:Visualization A
.
Making an element invisible
You can configure the property
in order to hide an element in the visualization.For the text field element configure the property
withError detected: Do the following...
.Configure the property dark red.
withIn
PLC_PRG
declare the variablebIsInvisible : BOOL : TRUE;
(this is the initialization for the current example; normally the variable should be set to TRUE by the application program under certain conditions.Configure the property
withPLC_PRG.bIsInvisible
.Build, download and start the application.
- ⇒
The application is running. The visualization opens and the text field is not visible. When you set
bIsInvisible
toTRUE
, the textfield will be displayed.