Page 1 of 1
If nothing selected macro command?
Posted: 2006-12-18 01:09:17
by Dirk_Barends
How can I 'force' a (Nisus perl) macro to _only_ run on selected text and, when there is no text selected, to not run at all?
I have found that the "Common Regexp Processing" macro needs such a line, because it reproduces the text when used for the second time without any text selected...
Posted: 2006-12-19 07:16:22
by ssampler
Here is a fix, but I don't know why it works. Add the line "#{text as rtf}" after the line "#destination front selection". Then the macro does nothing if nothing is selected.
Steve
indeed
Posted: 2006-12-19 07:29:53
by Dirk_Barends
yes it works for me too!
strange indeed though, wonder how you came to this solution.
Anyway big THANKS, saves me a lot of work!
Posted: 2006-12-19 07:50:37
by ssampler
Dirk,
You are very welcome. After seeing your post, I wondered if your problem would occur with a macro that I had written to change selected text; the problem did not occur. As the only relevant difference between my macro and "Common Regexp Processing" was the added line (p 195 of the Nisus Guide), the fix was easy to guess.
Steve
Posted: 2006-12-19 16:05:34
by martin
I've verified that running a macro with no text selected actually sends the whole document to the macro for processing. This is a bug and will be fixed in a future version. As for why "Send as RTF" fixes the issue: the bug only affects non-RTF perl macro input.