To use the “Text Editor” in the user interface to create or edit a text file on the controller, you need controls for selecting, opening, closing, saving, and creating a file in addition to the “Text Editor” element.
Example:

Configuring the “Text Editor” element, example
-
Drag a “Text Editor” element to the visualization editor.
-
For example, declare the control variables for the element as global variables in the
GVL
object.For more information, see the declaration of the control variables below.
-
For the “Text Editor”, configure the “Editor Mode” property with “Read/Write”.
-
Continue configuring the “Control variables” property.
Assign the following variables there:
-
“Control variables File Variable”:
g_sFileName
-
“Control variables File Open”:
g_bFileOpen
-
“Control variables File Close”:
g_bFileClose
-
“Control variables File Save”:
g_bFileSave
-
“Control variables File New”:
g_FileNew
-
Declaration of 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 a “Label” element.
-
Configure it in the “Texts Text” property with
File
. -
Add a “Rectangle” element next to it.
-
Configure its “Texts Text” property with
%s
. -
Configure its “Texts Text variable” property with
g_sFileName
. -
Configure the “Input configuration OnMouseclick” property with “Write Variable”.
In the “Input configuration” dialog, select “Input type” as the “Text input”.
Select the “Use text output variable” option.
The box to input the file name is configured.
-
Add a “Button” element.
-
Configure its “Texts Text” property with
New
. -
Configure the “Input configuration OnMouseclick” property with “Switch Variable”.
Assign
g_bFileNew
as the variable.The
New
button is configured. -
Add another “Button” element.
-
Configure the “Texts Text” property with
Open
. -
Configure the “Input configuration OnMouseclick” property with “Switch Variable”.
Assign
g_bFileOpen
as the variable.The
Open
button is configured. -
Add another “Button” element.
-
Configure its “Texts Text” property with
Save
. -
Configure the “Input configuration OnMouseclick” property with “Switch Variable”.
Assign
g_bFileSave
as the variable.The
Save
button is configured. -
Add another “Button” element.
-
Configure its “Texts Text” property with
Close
. -
Configure the “Input configuration OnMouseclick” property with “Switch Variable”.
Assign
g_bEditFile
as the variable.The
Close
button is configured.