Page 1 of 1

Runaway Macro

Posted: 2020-08-26 13:51:28
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'".
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?

Re: Runaway Macro

Posted: 2020-08-26 13:54:30
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;

Re: Runaway Macro

Posted: 2020-08-26 16:11:12
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?)

Re: Runaway Macro

Posted: 2020-08-26 16:17:46
by phspaelti
Here is a macro which does the same:

Code: Select all

Find and Replace '[\r\n]+(?=\X)', ' ', 'EasS'
Find and Replace ' +', ' ', 'EasS'

Re: Runaway Macro

Posted: 2020-09-02 10:20:35
by martin
allenwatson wrote:
2020-08-26 13:51:28
How 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.