Configuring the Editing of a Text File¶
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:
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 Read/Write.
withAlso configure the property
.Assign the following variables there:
g_sFileName
with g_bFileOpen
with g_bFileClose
with g_bFileSave
with g_FileNew
with
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
Add an element Label.
Configure it in the property
withFile:
.Add an element Rectangle next to it.
Configure its property
with%s
.Configure its 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.
Configure its property
withNew
.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
withOpen
: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
withSave
.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
withClose
.Configure the property Toggle a variable.
withAssign
g_bEditFile
as a variable.- ⇒
The button
Close
is configured.
See also