Pausing a Macro for User Interaction

Get help using and writing Nisus Writer Pro macros.
Post Reply
rcgordon
Posts: 32
Joined: 2003-07-22 01:31:29

Pausing a Macro for User Interaction

Post by rcgordon »

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

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

if $theResult = > 0
Select All
Select Start
Find and Replace "Something", "" "!Ea" #
Show Find...
##WAIT FOR USER INTERACTION TO COMPLETE, THEN CONTINUE OR QUIT.
end

How can I implement my commented pseudocode?
rcgordon
Posts: 32
Joined: 2003-07-22 01:31:29

Post by rcgordon »

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.

Strategy?
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Post by martin »

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:

Code: Select all

$action = "Continue" 
While $action == "Continue" 
   if Find "whatever" 
      $action = Prompt Options "Would you like to continue?", "", "OK", “Continue”, "Stop" 
   else 
      $action = "Stop" 
   end 
End
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.
rcgordon
Posts: 32
Joined: 2003-07-22 01:31:29

Post by rcgordon »

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.
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Post by martin »

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.
rcgordon
Posts: 32
Joined: 2003-07-22 01:31:29

Post by rcgordon »

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.
Post Reply