The system provides two possibilities of searching and replacing text elements in code and variables worksheets: Local and global text search/replacement.
The find function is applied to comments, variables, function/function block names, FB instance names, formal parameter names, contacts, and coils. For text replacement some rules/restrictions apply. Refer to the section "Rules for replacing text elements" below.
Finding/replacing text elements locally only affects the active worksheet. The global find/replace operation is applied to several or all worksheets, depending on your selection in the 'Global Find/Global Replace' dialog.
No "replace all matches" functionality is available. Instead, each replacement must be performed individually.
In ST POUs, the following restrictions apply to both the global and local text search:
No text replacements using the 'Find and Replace' function can be done. You can only find text and overwrite it manually.
Only the search direction 'Down' is supported.
The search function is not available while the ST editor runs online mode.
For both local and global operation, the 'Find/Replace' dialog is used. The dialog provides different search/replace options for local and global operation as listed in the dialog description.
Left click into the code or variables worksheet where you want to find or replace text.
Select 'Edit > Find...' to open the 'Find/Replace' dialog.
In the 'Find What' dialog field, enter the text string to be found/replaced or select an entry from the drop-down list.
Only for text replacement: In the 'Replace With' field, enter the new string or select an entry from the drop-down list.
Observe the restrictions mentioned in the note above.
Mark one or both search options ('Whole word' or 'Match Case').
Modify the search direction if desired.
Click 'Find Next' to start the search operation within the worksheet. The first match of this text element is marked.
Click 'Replace' to replace this match and find the next one.
To find/replace text only in particular worksheets or POUs, mark the related icons in the project tree. Multi-selection is possible by holding the <Ctrl> or the <Shift> key pressed while left clicking the desired tree icons.
Select 'Edit > Global Find...' (even if you want to replace text). The 'Global Find/Global Replace' dialog appears.
In the 'Find What' dialog field, enter the text string to be found/replaced or select an entry from the drop-down list.
Only for text replacement: In the 'Replace With' field, enter the new string or select an entry from the drop-down list.
Observe the restrictions mentioned in the note above.
Mark one or several of the options (see dialog description).
Using the checkboxes in the 'Selection' dialog area, you can include/exclude worksheet types.
Modify the search direction if desired.
To apply the search/replacement only to the worksheets selected in step 1, activate the 'Marked' radio button.
If 'All' is activated, any selection in the project tree is ignored.
Click 'Find Next' to start the search operation. The first match of this text element is marked.
Click 'Replace' to replace this match and find the next one.
The following table shows which elements can be replaced in which worksheet.
Yes = Replaceable/No = Not replaceable
The following rules do not apply to ST POUs. In ST, no text replacements using the 'Find and Replace' function can be done.
|
Variable name |
Constant |
Data type |
Usage |
Comment |
Terminal |
Initial value |
Local variables worksheet |
Yes |
No |
No |
Yes |
Yes |
No |
Yes |
Code worksheet |
Yes |
Yes |
No |
No |
Yes |
No |
No |
Global variables worksheet |
Yes |
No |
No |
No |
Yes |
No |
Yes |
Using the commands 'Edit > Find Previous' or 'Edit > Find Next' the same text element can be searched again without using the 'Find' dialog (search direction 'Up' or 'Down' as set in the dialog). Both commands are available for local and global search operations.
Dialog element |
Meaning |
---|---|
Find What: |
String to be found/replaced. |
Replace With: |
Replacement string (only available on the '(Global) Replace' tab). |
Whole word |
The found text has to match with the whole search text. |
Match Case |
If activated, the search is done case-sensitive: only text matching upper and lower cases of the entered word is found. |
'Selection' area |
Worksheet types to which the search/replace operation is to be applied (only available for global text operation). |
Direction:'Up' or 'Down' |
Search direction in the worksheet.
NOTE:
In ST code, only the search direction 'Down' is supported. |
Range'All' or 'Marked' |
Range of worksheets included in the search/replace operation (only available for global text operation).
|
Find Next |
Searches for the next text element. |
Replace |
Replaces the found and marked text match by the text specified in the 'Replace With' field.
NOTE:
No "replace all matches" functionality is available. Instead, each replacement must be performed individually. Observe the restrictions for ST POUs mentioned in the note in section "General Information..." above. |