nisus.com
https://www.nisus.com/forum/

Macro language changes
https://www.nisus.com/forum/viewtopic.php?f=17&t=3229
Page 1 of 1

Author:  Groucho [ 2008-11-12 01:22:42 ]
Post subject:  Macro language changes

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:
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:
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:
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:
Find '(?<=[0-9])(th|nd|rd|st)\>', 'aE'
Format:Baseline:Superscript


Now it does work finely.

Greetings, Henry.

Author:  martin [ 2008-11-12 01:39:30 ]
Post subject:  Re: Macro language changes

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:
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.

Quote:
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:
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.

Author:  Groucho [ 2008-11-12 02:00:51 ]
Post subject:  Re: Macro language changes

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.

Author:  martin [ 2008-11-12 02:46:21 ]
Post subject:  Re: Macro language changes

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.

Quote:
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.

Author:  Groucho [ 2008-11-12 07:31:53 ]
Post subject:  Re: Macro language changes

Thank you very much.

Henry.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/