Runaway Macro

Get help using and writing Nisus Writer Pro macros.
Post Reply
allenwatson
Posts: 34
Joined: 2005-10-05 15:05:51
Location: Portland, OR
Contact:

Runaway Macro

Post by allenwatson »

I just executed a macro from the Macro menu. It has been running for nearly an hour!In the status bar at the bottom of the screen, I see this:
"Running Macro 'Form Paragraphs.pl'".
I am unable to run any other macros. If I try, a dialog comes up asking if I want to continue the running macro or stop it and run a new one, but if I select the latter, the runaway macro does not stop.

How can I stop it besides quitting and re-opening Nisus?
allenwatson
Posts: 34
Joined: 2005-10-05 15:05:51
Location: Portland, OR
Contact:

Re: Runaway Macro

Post by allenwatson »

Here is the source of the runaway macro. It must contain a bug, but I don't know Perl much. How can I fix it?

#Nisus Macro Block
#source front selection
#destination front selection
#End Nisus Macro Block
use strict;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");

my $text;
while (my $line = <STDIN>) {
$line =~ s/[\r\n]+//g;
$text .= "$line ";
}
$text =~ s/ +/ /g;
print $text;
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Runaway Macro

Post by phspaelti »

Hello Allen,
There is nothing wrong with this macro (unless you count it's ante-diluvian syntax :D ) .
And when I try it, it runs without a hitch. The macro uses perl to remove carriage returns and reduce strings of spaces from the current selection. As an added benefit :P it will remove (or "flatten") the formatting of your selection as well.
There is really no good reason for keeping such macros around. Even if you absolutely wanted to use perl for such a task, you could do it without the macro block construct.

I'm not sure why it didn't terminate for you. Maybe it has something to do with the way you ran it? (What was selected at the time?)
philip
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Runaway Macro

Post by phspaelti »

Here is a macro which does the same:

Code: Select all

Find and Replace '[\r\n]+(?=\X)', ' ', 'EasS'
Find and Replace ' +', ' ', 'EasS'
philip
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Runaway Macro

Post by martin »

allenwatson wrote: 2020-08-26 13:51:28How can I stop it besides quitting and re-opening Nisus?
If a macro is taking too long to finish executing you can abort it by pressing the Esc (Escape) key on your keyboard, or the keyboard shortcut Command + Period.
Post Reply