Configuring the Display of a Text File¶
In order to display a text file that is located on the controller, you need not only the element Text editor, but also control elements for selecting, opening and closing the file. Optionally a text search function can be set up in the file with further control elements.
Example:
Drag an element Text editor into the visualization editor.
Declare the control variables for the element, for example as global variables in the
GVL
object.- ⇒
Refer to the declaration of the control variables for this.
For the text editor, configure the property Read only.
withAlso configure the property
.Assign the following variables there:
g_sFileName
with g_bFileOpen
with g_bFileClose
with g_bFileNew
with g_bFileSave
with g_sEditSearchFor
with g_bEditFind
with g_bEditFindNext
with
Declaring the control variables
VAR_GLOBAL
g_sFileName: STRING := 'Readme.txt';
g_bFileOpen : BOOL;
g_bFileClose: BOOL;
g_bFileNew: BOOL;
g_bFileSave: BOOL;
g_sEditSearchFor : STRING;
g_bEditFind : BOOL;
g_bEditFindNext : BOOL;
g_usiErrorHandlingVarForErrorCode: USINT;
g_bVarForContentChanged : BOOL;
g_bVarForReadWriteMode: BOOL;
END_VAR
Add an element Label.
Configure the property
withFile:
.Add an element Rectangle next to it, in which the user can then enter the file name:
Configure the property
with%s
:Configure the property
withg_sFileName
.Configure the property Write a variable.
withIn the dialog Input Configuration, select Text input as the Input type.
Activate the option Use text output variable.
- ⇒
The rectangle for the input of the file name is configured.
Add an element Button for opening the file.
Configure the property
withOpen
:Configure the property Toggle a variable.
withAssign
g_bFileOpen
as a variable.- ⇒
The button
Open
is configured.
Add a further element Button for closing the file.
Configure the property
withClose
:Configure the property Toggle a variable.
withAssign
g_bEditFile
as a variable.- ⇒
The button
Close
is configured.
Add an element Label.
Configure the property
withText:
.Alongside it, add an element Rectangle for the input of the text to be found.
Configure the property
with%s
:Configure the property
withg_sEditSearchFor
.Configure the property Write a variable.
withIn the dialog Input Configuration, select Text input as the Input type.
Activate the option Use text output variable.
- ⇒
The rectangle is configured.
Add an element Button for starting the search.
Configure its property
withFind
.Configure the property Toggle a variable.
withAssign
g_bEditFind
as a variable.Also add the action Execute ST-Code.
Program the action with:
g_bEditFindNext := FALSE;
- ⇒
The button is configured.
Add a further element Button.
Configure the property
withFind next
.Configure the property Toggle a variable.
withAssign
g_bEditFind
as a variable.Also add the action Execute ST-Code.
Program:
g_bEditFindNext := TRUE;
- ⇒
The button is configured.
See also