S T R U C T O R I Z E R - User Guide
Features > Find & Replace

If you have to deal with a significant number of diagrams, powerful editing capabilities get essential. You may want to search for diagrams and elements containing certain substrings and to perform consistent changes (e.g. variable renaming) even throughout several diagrams.

The Find & Replace dialog offers a variety of helpful selection and modification opportunities in various combinations:

Find & Replace dialog

Activation

There are several ways to open the File & Replace dialog:

  • by pressing the speed button binoculars in the toolbar;
  • by entering the accelerator key combination <Ctrl><F>;
  • via the Edit menu:
    Edit menu version 3.27 with F & R selected

Find and Replace Patterns

At the window top you enter your textual search pattern, either interpreted as plain substring or as regular expression (depending on whether checkbox "Regular expressions" is selected).

Beneath the search pattern you may enter a replacing string or pattern if you intend to substitute one or more of the found substrings. If the Regular expressions checkbox is selected then the replacement may contain placeholders like $1, $2 etc. which refer to the content of the first, second and so on group of the regular expression match. (A group in a regular expression is a sub-pattern in parentheses, like ([0-9][0-9]) in the screenshot above, which would mean $1 to be 00, 02, 04, respectively, for the first, the second, and the third match).

The Find & Replace dialog keeps a history of depth 10 for each of the two pattern fields, which is available via the respective pulldown button.

Mode settings (left-hand side)

Here you may specify the search direction and how the patterns are to be interpreted.

Direction "down" means to traverse the search results from top to bottom and the matches within a single text in forward direction. Direction "up" is the opposite (bottom to top, from right to left).

The checkbox "Regular expressions" specifies - if selected - that the patterns be interpreted as regular expressions with extactly the syntax accepted by Java class java.util.regex.Pattern. Since a complete description would exceed the scope of this user guide, just some examples:

PatternMatchesExamples
b.y All three-character substrings starting with b and ending with y bay, boy, buy
b.?y Substrings with at most one character between b and y by, buy, b2y
b[a-z]*y Substrings with any number of lower-case letters between b and y by, bay, buoy, baby, belly, balcony
b[a-z]*?y Substrings with minimum number of lower-case letters between b and y the ones before except baby (where by is the smaller match)

The checkboxes "Case-sensitive" and "Whole word" are only selectible if "Regular expressions" is unchecked. Regular expressions may specify themselves whether case matters or how a substring be surrounded in order to match, though with some effort - in order to match the word "result" case-independently and as isolated word, you might write the following regular expression:

(^|\W)[Rr][Ee][Ss][Uu][Ll][Tt](\W|$)

In plain-string mode, case does not matter by default, and the pattern may be any substring, such that a search string BY would be found within Babylon.
By selecting any of the checkboxes "Case-sensitive" and "Whole word", however, the above case would no longer be a match.

Scope settings (left-hand side)

You may choose the search scope among

  • all diagrams currently held in Structorizer and Arranger,
  • just the current diagram in Structorizer (Arranger not searched), and
  • just the currently selected sequence of elements in the current diagram (including substructure).

The result presentation and navigation in the central view of the dialog will differ among the first choice (multi-diagram) and the other two options (single-diagram), see "Result view" below.

If you opted for all opened diagrams then you may restrict the search to certain diagram types (i.e. any subset of them).

Then you may specify whether the element texts and/or the element comments are to be involved in the search. (To exclude both doesn't make sense, of course.)

Element types (right-hand side)

You may limit the search to any subset of element types, e.g. to exclude Call elements from search. The All and None button are to facilitate selecting or unchecking all element types at once.

Independently of the element type choice, you may or may not include disabled elements.

Result view (central)

When you have specified all search criteria according to the opportunities above, pressing the "Find" button will start the search.

In case of scope "Opened diagrams", the central view will show the tree (or "forest") of all found elements in all present diagrams. The diagrams containing elements with matches form the roots, the elements are the subnodes (leaves) of their respective parent diagram. All elements with matches in texts or comments appear at the same level, no matter how deep they were nested. If you don't see elements below a diagram root then just click on the respective root in order to expand the subtree. If the diagram header element itself holds a match then it will also be shown at the element level. In forward mode, the first matching element (in the first presented root) will be selected and its text and comment appear in the preview text areas at the dialog bottom. If there are several matches within the enabled text areas then all but one are highlighted in yellow, the very current match within the text has orange background (see figure above).

The further navigation depends on whether checkbox "Element-wise" (in the lower left corner next to the buttons) is selected or not: If not then the next click on "Find" will move the orange spot to the next match within the text of the same element, if checked, however, the presentation skips to the next element from the result list ("fast" mode).

You may change navigation direction by switching the radio buttons "down" and "up", thus going back to previous matches.

If the scope was not "Opened diagrams" but either "Current diagram" or "Current selection") then the search results won't be presented at once in the tree but traversed incrementally. You'll see only the current element as node and whether there is another match before and after:

Find & Replace dialog in current diagram mode

In the screenshot above, scope "Current diagram" was chosen, and the result view indicates that the currently inspected instruction element has matching predecessors (by the pseudo-node with the ellipse above) but no successors (otherwise there would be another pseudo-node below it). So you have a very limited overview, but on the other hand, the current diagram in the Structorizer work area will synchronously scroll to the current search result and highlight it, while you navigate up / down with "Find" in the Find & Replace dialog. This way, you can see its exact position within the diagram, which was not possible with the multi-diagram scope.

Buttons

The Find button starts search (if result view was empty or exhausted) or moves the spot to the next/previous match within the text of the current element ("Element-wise" off) or to the next node of the search result ("Element-wise" on).

Button Replace/Find will replace the currently focussed match and then move to the next match the way the Find button would do. Be aware that doing the replace action with empty replace pattern field will delete the matching substring.

Button Replace just replaces the spotted match without moving the spot afterwards.

Button Replace All will blindly replace all matches from the currently selected match on towards the end of the search result set in the specified navigation direction (down/up). So it doesn't always really mean "all".

Every single replacement is undoable (and redoable) in reverse order, but only from the respective diagram, which must be summoned to the Structorizer window.

The Close button will simply hide the Find & Replace dialog, all settings will be maintained and will still be present on reopening the dialog. Most criteria and the pattern histories will even be saved in the structorizer.ini file on ending the session such taht they will be restored in the next Structorizer session.