On Thursday, August 14, 2003, at 08:04 PM, Patrick Gormley wrote:
Has anyone had success in writing a Perl macro that sends the selected text to the macro as RTF (using the #send RTF) option and having the text returned and formatted as RTF? The documentation included does not say much on the subject. I am a chemistry teacher and would like to design a macro that would take text like Na2SO4 and have the macro drop all numbers to subscripts. I had one of these in that worked like a charm in Nisus Writer 6.x, but with no conversion utility I am forced to try and do this in Perl. If anyone can help, or point me in the direction of some good references, I would be really appreciate > it.
My short answer is, no, unfortunately, no, I think I would be unable to create such a macro for NW-Ex. But this is a good opportunity to think about what Classic Nisus Writer macro could do, and what macros for NW-Ex are unable to do.
In Classic NW macro, this task could have been done most easily, with a simple two line macro:
Find In Selection ":d+" "g-St"
Subscript
With NW-Ex macro, what could we do? To deal with style, the easiest way would be to use the menu command macro; but while it is possible to write the command "Format:Subscript", it is impossible, as far as I know, to write macro command for Find or Find/Replace functions. So, the menu command macro would not work for this task.
The second choice is the AppleScript macro. While it is possible to get the text of the selection, it is impossible to set the selection to anything we would want. It is possible, probably, to set the style of the text of such or such numeric index to something, but it is impossible, as far as I know, to get the offset of the selection either. So, this task would be impossible to achieve with AppleScript macros.
The third and final choice is the Perl macro. But to deal with styles in Perl macro, we must use the "Send Text as RTF" directive -- but then, again as far as I know, if we use this directive, ALL the rtf data will be sent to Perl, so we cannot change the selection only, and we cannot know the offset of the selection...
It would be possible to write a Perl macro which would set ALL the digits in the text to subscript style, but I think this is not what Patrick would want.
If you have a list of all the strings in which all the numbers must be set to the subscript style, perhaps I would be able to write a macro -- but running this macro as you write your text, and changing all your text each time would be not practical at all...
These impossibilities in the current implementation of the three kinds of macro show exactly what we need so badly now:
1. For the menu command macro: the possibility of writing Find/Replace commands in the menu command macros.
2. For the AppleScript macro: the possibility of "set selection to" anything we would want; and the possibility of getting the offset of the selection (both, or either in bytes and/or in characters).
3. For the Perl macro: the possibility of dealing with the selection(s) only; the possibility of sending the rtf data of the selection(s) only, and getting back the rtf data of the selection(s) only; and the possibility of getting the offset of the selection(s) (in rtf data, and in text).
4. And also, the possibility of merging all the three kinds of macros...
These are the most pressing wish list. I hope the Nisus development team will read this message...!
BUT as I repeatedly said, perhaps I am missing something obvious, and people more skilled than I can write the wanted macro. I really hope so!
Yusuke...??
Best regards,
Nobumi Iyanaga Tokyo, Japan
P.S. I was to send this posting, and I just received the answer by Yusuke. How intelligent!
But I still think that my message is not entirely useless. So I send it all the same...
--------------------------------------------------- The Nisus Interactive List [EMAIL PROTECTED]
Searchable archives: http://www.mail-archive.com/nisus-interactive%40nisus.com/
To unsubscribe from this list please send a message with "unsubscribe nisus-interactive" in the body of the email to [EMAIL PROTECTED]
