Page 1 of 1

Different behavior from what looks to me like similar macros

Posted: 2020-08-14 21:06:46
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

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

Posted: 2020-08-14 22:29:34
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?

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

Posted: 2020-08-15 03:29:58
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

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

Posted: 2020-08-15 07:27:13
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 8783 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.

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

Posted: 2020-08-15 15:10:03
by macosxguru
Thank you. I will play with this some more.

macosxguru