Pausing a Macro for User Interaction
Page 1 of 1

Author:  rcgordon [ 2007-07-13 13:10:43 ]
Post subject:  Pausing a Macro for User Interaction

How can I set up a pause for interaction with the option to continue or stop the macro?

$theResult = Find "Something", "vEa"
Prompt "$theResult instances found."

if $theResult = > 0
Select All
Select Start
Find and Replace "Something", "" "!Ea" #
Show Find...

How can I implement my commented pseudocode?

Author:  rcgordon [ 2007-07-13 13:38:12 ]
Post subject: 

In case my intent isn't clear enough, I want the user to be able to manually screen or operate individually through a manual Find routine which may repeat an unknown number of times. Since the manual find routine may involve attribute sensitivity, embedding all of this into a Perl routine is not an option.

The problem with just aborting the macro if user interaction is required means picking it up midstream afterwards.


Author:  martin [ 2007-07-13 14:22:14 ]
Post subject: 

To answer your specific question, it is not possible to pause the macro execution until the user closes the Find dialog. However, I bet what you want to do can be accomplished using a While loop and some customized prompts. Eg:

$action = "Continue"
While $action == "Continue"
   if Find "whatever"
      $action = Prompt Options "Would you like to continue?", "", "OK", “Continue”, "Stop"
      $action = "Stop"

As for your specific macro, I'm not sure I understand what you want to do exactly. If you could describe it more, I might be able to give you some better advice.

Author:  rcgordon [ 2007-07-13 16:18:48 ]
Post subject: 

I didn't include a real-life scenario, but I am trying to use NWP for processing coded text (as I have for years with NW Classic).

Since this forum will not all attribute sensitive code to make any sense, let me just pose this scenario.

Prior to this search, within the same text processing macro, all code text has been tagged with a character style, for reference and viewing purposes. (Think syntax coloring. Many other elements have been colored, and a bunch of cleanup has already occurred.)

I set up a search to first of all search for text in the standard style to remove multiple spaces automatically.

Then I check for the existence of multiple spaces within text styled as code, and then allow the user (i.e., me) to manually search through those, so that I can deal with them in a way that I need to determine from the context. (Is it accidental or extraneous? Should the be converted to tabs or single spaces?)

Then I want to continue with my text processing macro.

Author:  martin [ 2007-07-13 16:31:39 ]
Post subject: 

Thanks for the extra explanation. Unfortunately there's not currently any way to accomplish this. A macro continues running uninterrupted until it finishes or is cancelled.

I might suggest that you structure your macro so it can easily resume its work from the last point that required manual user interaction. The best would be to apply a bookmark in the file at the restart point. Then when the macro is started it can check for the existence of this custom bookmark and restart there.

Author:  rcgordon [ 2007-07-13 16:50:47 ]
Post subject: 

OK. I'll start making extensive use of bookmarks in my macros. I've got some other questions, but I'll post them so they're not buried under the wrong topic.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group