Jonathan,
Maybe I've got my e-mails mixed up but I have the following as your original script (dated Aug 16, 2003 on the list):
@myfile=<STDIN>;
foreach $s (@myfile){
1. $s=~s/([A-Z][a-z]?[0-9]*)([+-])/$1\{\\super $2\}/g;
2. $s=~s/\)([+-])/\)\{\\super $1\}/g;
3. $s=~s/([A-Z][a-z]?)([0-9]+)/$1\{\\sub $2\}/g;
4. $s=~s/\)([0-9]+)/\)\{\\sub $1\}/g;
print $s;
}


This script did not handle all superscripts correctly so I revised line 1 to look like what you have below in line 2. Then I added a new line one, giving a new script which had 5 lines. This was my first revision, which I posted to the list. It worked on all formulas except formulas like Cu(H2O)62+. A few hours later I added a 6th line which is the line 4 you mentioned below and it now handled all formulas correctly.

Maybe you and I both came up with the 6 line version independently or I got my e-mail messages mixed up. I have been having a lot of e-mail problems since the power outage. Still cannot get into my school e-mail account. Hope they get the problem cleared up before school starts Friday.
On Monday, August 18, 2003, at 02:37 PM, Jonathan Levi, M.D. wrote:


Hi Patrick,

My apologies for not looking more closely at your revision of my script.
I've looked at it now, and still have my questions regarding syntactic ambiguity. First, let me list the substitution statements from your modification vs my original; I am inserting line numbers:


Your revision:
1.      $s=~s/([A-Z][a-z]?[0-9]*)([0-9][+-])/$1\{\\super $2\}/g;
2.      $s=~s/([A-Z][a-z]?)([0-9]*[+-])/$1\{\\super $2\}/g;
3.      $s=~s/\)([+-])/\)\{\\super $1\}/g;
4.      $s=~s/([A-Z][a-z]?)([0-9]+)/$1\{\\sub $2\}/g;
5.      $s=~s/\)([0-9]+)/\)\{\\sub $1\}/g;

My original:
1.      $s=~s/([A-Z][a-z]?[0-9]*)([0-9][+-])/$1\{\\super $2\}/g;
2.      $s=~s/([A-Z][a-z]?)([0-9]*[+-])/$1\{\\super $2\}/g;
3.      $s=~s/\)([+-])/\)\{\\super $1\}/g;
4.      $s=~s/\)([0-9]+)([0-9][+-])/\)\{\\sub $1\}{\\super $2\}/g;
5.      $s=~s/([A-Z][a-z]?)([0-9]+)/$1\{\\sub $2\}/g;
6.      $s=~s/\)([0-9]+)/\)\{\\sub $1\}/g;

Clearly, my original has one more substitution then your revision; line-by-line comparison seems to show me that the only difference is that you have deleted my line 4, leaving everything else unchanged.

As I see it, my line 4 is needed to handle a formula such as the following, from your list of formulas:

Cu(H2O)62+

as you currently have no line that handles the combination of a right parenthesis, digits, and a sign. (Indeed, when I made a Nisus macro file from your revised script and a source file from your list of formulas, the + following the 62 did not receive a superscript.)

The missing line in my original script handles this combination, but locks one into using the last digit and only the last digit as part of the superscript. As I discussed previously, this might not actually be what you want: I gave the hypothetical example "S2-" and noted that conceivably we might want the 2 to modify either the S or the -, but neither of our scripts gives us a mechanism to make that choice. Accordingly, I suggested the insertion of a colon as a way to tell the macro how that digit is to be handled.

I'll be happy to continue the discussion of this macro if you wish. In any case, thank you for inducing me to make my introduction to the macro system of Nisus Writer Express.

Sincerely,

Jonathan At 10:30 AM -0400 8/18/03, Patrick Gormley wrote:

--
Patrick Gormley
Lapeer East High School
Lapeer MI 48446
http://chem.lapeer.org
--A generation which ignores history has no past and no future.
----Robert Heinlein




--------------------------------------------------- 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]




Reply via email to