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
GVLobject.- ⇒
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
- 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 with
File:.Add an element Rectangle next to it.
Configure its property with
%s.Configure its property with
g_sFileName.Configure the property with Write a variable.
In 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 with
New.Configure the property with Toggle a variable.
Assign
g_bFileNewas a variable.- ⇒
The button
Newis configured.
Add a further element Button.
Configure the property with
Open:Configure the property with Toggle a variable.
Assign
g_bFileOpenas a variable.- ⇒
The button
Openis configured.
Add a further element Button.
Configure its property with
Save.Configure the property with Toggle a variable.
Assign
g_bFileSaveas a variable.- ⇒
The button
Saveis configured.
Add a further element Button.
Configure its property with
Close.Configure the property with Toggle a variable.
Assign
g_bEditFileas a variable.- ⇒
The button
Closeis configured.
See also