If nothing selected macro command?

Have a problem? A question? This is the place for answers from other Express users.
Post Reply
Dirk_Barends
Posts: 42
Joined: 2006-12-14 09:09:51

If nothing selected macro command?

Post 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...
ssampler
Posts: 85
Joined: 2006-06-29 07:56:30
Location: Hudson River Valley, NY

Post 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
Dirk_Barends
Posts: 42
Joined: 2006-12-14 09:09:51

indeed

Post 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!
ssampler
Posts: 85
Joined: 2006-06-29 07:56:30
Location: Hudson River Valley, NY

Post 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
Last edited by ssampler on 2006-12-21 09:09:56, edited 1 time in total.
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

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