In order to be able to create a new text file or edit an existing one on the controller with the Text Editor in the user interface, you need not only the element Text Editor, but also control elements for selecting, opening, closing, saving and creating a file.
Example:
Configuring the element Text Editor, 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 below to the declaration of the control variables for this.
For the Text Editor, configure the property with Read/Write.
Also configure the property
.Assign the following variables there:
with
g_sFileName
with
g_bFileOpen
with
g_bFileClose
with
g_bFileSave
with
g_FileNew
Declaring the control variables
VAR_GLOBAL
g_sFileName: STRING := 'Readme.txt';
g_bFileOpen : BOOL;
g_bFileClose: BOOL;
g_bFileSave: BOOL;
g_FileNew: BOOL;
g_usiErrorHandlingVarForErrorCode: USINT;
g_bVarForContentChanged : BOOL;
g_bVarForReadWriteMode: BOOL;
END_VAR
Configuring control elements for file selection
Add an element Label.
Configure it in the property File:
.
Add an element Rectangle next to it.
Configure its property %s
.
Configure its property g_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.
Configure its property New
.
Configure the property Toggle a variable.
withAssign
g_bFileNew
as a variable.
⇒ The button New
is configured.
Add a further element Button.
Configure the property Open
:
Configure the property Toggle a variable.
withAssign
g_bFileOpen
as a variable.
⇒ The button Open
is configured.
Add a further element Button.
Configure its property Save
.
Configure the property Toggle a variable.
withAssign
g_bFileSave
as a variable.
⇒ The button Save
is configured.
Add a further element Button.
Configure its property Close
.
Configure the property Toggle a variable.
withAssign
g_bEditFile
as a variable.
⇒ The button Close
is configured.
See also