Macro language changes

Get help using and writing Nisus Writer Pro macros.
Post Reply
Groucho
Posts: 496
Joined: 2007-03-03 09:55:06
Location: Europe

Macro language changes

Post by Groucho » 2008-11-12 01:22:42

I noticed a couple of changes in macro language that are not advertised in the Nisus Macro Reference file (that I know of).
I used this pattern in some of my macros:

Code: Select all

while Find 'sometext', 'E'
   if condition 1
   do this
   elseif condition 2
   do something else
end
Now, in version 1.2, I get an error in the parsing phase (the while command expected an end). So I had to change the pattern as follows:

Code: Select all

while Find 'sometext', 'E'
     if condition 1
     do this
     elseif condition 2
     do something else
     end
end
Looks like Nisus macro language got stricter. Or, did I miss something?
...
Here is another, pretty simple, macro. I used this to superscript ordinals like 1st, 62nd 34th and so on in an imported file, since FixIt only works when one is typing. The original macro was:

Code: Select all

Find '(\d)(st|nd|rd|th)', '\1\2', 'EaU'
Where \2 was superscript (just selected and applied a baseline:superscript style).
It worked OK until version 1.1. With version 1.2 font attributes are applied entirely. That is, captured text is converted to Monaco 12pt etc., which is my macro style. Then I had to change the macro as follows:

Code: Select all

Find '(?<=[0-9])(th|nd|rd|st)\>', 'aE'
Format:Baseline:Superscript
Now it does work finely.

Greetings, Henry.

User avatar
martin
Official Nisus Person
Posts: 4287
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Macro language changes

Post by martin » 2008-11-12 01:39:30

Groucho wrote:I noticed a couple of changes in macro language that are not advertised in the Nisus Macro Reference file (that I know of).
I used this pattern in some of my macros:

Code: Select all

while Find 'sometext', 'E'
   if condition 1
   do this
   elseif condition 2
   do something else
end
Now, in version 1.2, I get an error in the parsing phase (the while command expected an end).
The pattern you were making use of was never supported and wasn't accomplishing what you thought. If you had added a line after the last "end" in your macro it would have been executed as part of the loop body, even though you thought it was external to the loop.
I used this to superscript ordinals like 1st, 62nd 34th and so on in an imported file, since FixIt only works when one is typing. The original macro was:

Code: Select all

Find '(\d)(st|nd|rd|th)', '\1\2', 'EaU'
Where \2 was superscript (just selected and applied a baseline:superscript style).
It worked OK until version 1.1. With version 1.2 font attributes are applied entirely.
I'm not sure this behavior was changed, but the "U" option should always have applied all styles/formatting present in the macro file. Perhaps we fixed a bug. If you really want to accomplish the task using a Replace operation, strip all styles/formatting from that particular line in your macro file.

Groucho
Posts: 496
Joined: 2007-03-03 09:55:06
Location: Europe

Re: Macro language changes

Post by Groucho » 2008-11-12 02:00:51

Thanks, Martin. Whether supported or not, the modified pattern works now, as it worked previously. Chance? Or am I in for some unexpected trick sooner or later?
As for the second instance, I supposed so; that is I supposed that the text being replaced had to be stripped of all attributes except baseline. Anyway, I find the second macro more fitting and less error-prone--but this is only my opinion.

Cheers, Henry.

User avatar
martin
Official Nisus Person
Posts: 4287
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Macro language changes

Post by martin » 2008-11-12 02:46:21

Groucho wrote:Thanks, Martin. Whether supported or not, the modified pattern works now, as it worked previously. Chance? Or am I in for some unexpected trick sooner or later?
No unexpected future unpleasantness- your modified pattern is exactly how the language is designed to be used.
As for the second instance, I supposed so; that is I supposed that the text being replaced had to be stripped of all attributes except baseline. Anyway, I find the second macro more fitting and less error-prone--but this is only my opinion.
I'm in agreement- I like seeing the change made explicitly. You never know when some invisible or unexpected attribute can sneak into some text.

Groucho
Posts: 496
Joined: 2007-03-03 09:55:06
Location: Europe

Re: Macro language changes

Post by Groucho » 2008-11-12 07:31:53

Thank you very much.

Henry.

Post Reply