PFE Logo


Application Note 6

Searching And Replacing Within Macros


A common requirement in macros is to perform searching and replacing operations, using EditFind, EditReplace and so on.

However, because of the current structure of the macro language, you may well find that you can't manage to program what you want.

The reason is that the macro language was (badly) designed to simulate typing of editor commands, and does not allow programmatic control of any dialog boxes that the commands generate

Thus, if you use the EditFind command in a macro, the Edit Find dialog will appear; and the macro, having executed that command, will carry on, leaving the modeless dialog sitting there waiting for you to type.

There is only one practicable way of handling searches in macros, which is not greatly useful. You can pre-load search and replace strings by using the Edit Find or Edit Replace dialogs before you run the macro; then, inside the macro, use the EditRepeatLastFind and EditRepeatLastReplace to repeat the operation exactly.

This is less than optimal, and in most cases macros are useless for searching and replacing. In PFE 2, which may begin to appear late in 1999, the macro language will be scrapped, and replaced by a fully-featured programming language that will allow complete programmatic control of everything.


Return to the PFE Home Page