Different behavior from what looks to me like similar macros

Get help using and writing Nisus Writer Pro macros.
Post Reply
macosxguru
Posts: 5
Joined: 2020-08-13 22:43:06

Different behavior from what looks to me like similar macros

Post by macosxguru »

This is in Nisus Writer Express version 4.1

This is the macro for bold:

Code: Select all

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

read STDIN,$text,10000;
$text = "**$text**";
print $text;
This is the macro for italic:

Code: Select all

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

read STDIN,$text,10000;
$text = "*$text*";
print $text;
When I apply the Bold micro to the words "Nisus Writer" This is what it puts on screen `** Nisus Writer**`. See the extra space after the first set of **'s?

When I select words, the words are selected without the space in front or behind them. I apply the macro, and undo the change, the space in front of my original selection is also selected, which explains the behavior. Why does it select the space in front of the selection when it was explicitly not selected before?

When I apply the italic macro, it doesn't have any extra space. How is this different and why?

macosxguru
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Different behavior from what looks to me like similar macros

Post by phspaelti »

How is this different and why?
I just tested your bold macro and I don't find that it adds an extra space. I get exactly the result you are expecting.

Having said that I am a Pro user not Express.

It's been a long time, so I do have to ask? I know that Express does not have all the functionality of Pro, of course, but is it still limited to the old macro block syntax? Is it not possible to write this with a (Find &) Replace expression? Or with "Insert/Type" commands?
philip
macosxguru
Posts: 5
Joined: 2020-08-13 22:43:06

Re: Different behavior from what looks to me like similar macros

Post by macosxguru »

Thanks Philip.

Unfortunately I don't have the answers to your question. I am a new user to Nisus Writer Express. Don't know how it is different from Pro.

I just copied the code from an existing macro in Express and wanted to see if it would work with bold and italic markup of Markdown.

macosxguru
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Different behavior from what looks to me like similar macros

Post by phspaelti »

I just checked the online manual for NWE, and it seems it should allow you to macroize Find expressions. Since the task you are looking for can easily be achieved using "Find and Replace", aka "PowerFind", you might be able to get the same that way.

The Find Expression you want looks like this:
Screen Shot 2020-08-16 at 24.16.41 .png
Screen Shot 2020-08-16 at 24.16.41 .png (114 KiB) Viewed 8628 times
If you macroize this expression (after switching to PowerFind Pro - easier to post here), you will get a one line macro like this:

Code: Select all

 Find and Replace ".+", "**\0**", 'Es-i'
This is to my mind at least, considerably more comprehensible than that archaic Macro Block stuff. YMMV.
philip
macosxguru
Posts: 5
Joined: 2020-08-13 22:43:06

Re: Different behavior from what looks to me like similar macros

Post by macosxguru »

Thank you. I will play with this some more.

macosxguru
Post Reply