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?
Runaway Macro
-
- Posts: 34
- Joined: 2005-10-05 15:05:51
- Location: Portland, OR
- Contact:
-
- Posts: 34
- Joined: 2005-10-05 15:05:51
- Location: Portland, OR
- Contact:
Re: Runaway Macro
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;
#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;
Re: Runaway Macro
Hello Allen,
There is nothing wrong with this macro (unless you count it's ante-diluvian syntax
) .
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
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?)
There is nothing wrong with this macro (unless you count it's ante-diluvian syntax

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

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
Re: Runaway Macro
Here is a macro which does the same:
Code: Select all
Find and Replace '[\r\n]+(?=\X)', ' ', 'EasS'
Find and Replace ' +', ' ', 'EasS'
philip
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Runaway Macro
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.