Reply to topic  [ 5 posts ] 
Macro language changes 
Author Message

Joined: 2007-03-03 09:55:06
Posts: 494
Location: Europe
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.


2008-11-12 01:22:42
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
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.


2008-11-12 01:39:30
Profile WWW

Joined: 2007-03-03 09:55:06
Posts: 494
Location: Europe
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.


2008-11-12 02:00:51
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
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.


2008-11-12 02:46:21
Profile WWW

Joined: 2007-03-03 09:55:06
Posts: 494
Location: Europe
Thank you very much.

Henry.


2008-11-12 07:31:53
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software