Well I'll try a fourth time. I keep getting a message from macjordomo stating that my messages contain an attachement, but there are none.


I tried the script posted here by Jonathan by creating a file that contained many possible combinations of subscripts and superscripted formulas. These are below:


Ca(SO4(H2O)2
Ca2+
S2-
6H2O
6Ca2+
4S2-
SO42-
3SO42-
6Cr2O72-
Cu(H2O)62+
Ni(CN)42-


I found that the original code did not always handle superscripts well so I made one change to the first line (changed the parans). This worked better. I then added another line of code and placed this first. Now everything works as expected except for the last two formulas above. The six and the 4 need to be subscripted and the 2+ and 2- need to be superscripted. The revised macro is below. Maybe someone can make the necessary revisions to get it to work with the last two formulas.


##My revisions
#!/usr/bin/perl
#Nisus Macro Block
#source front
#destination new
#Send Text as RTF
#End Nisus Macro Block

### dochemsubscripts.pl

# dochemsubcripts.pl -- perl script to sniff out molecular formulas in an
# RTF file and insert subscript tags for the numbers, superscript tags for
# ionic signs. JL 8/2003


@myfile=<STDIN>;
foreach $s (@myfile){
     $s=~s/([A-Z][a-z]?[0-9]*)([0-9][+-])/$1\{\\super $2\}/g;
        $s=~s/([A-Z][a-z]?)([0-9]*[+-])/$1\{\\super $2\}/g;
        $s=~s/\)([+-])/\)\{\\super $1\}/g;
        $s=~s/([A-Z][a-z]?)([0-9]+)/$1\{\\sub $2\}/g;
        $s=~s/\)([0-9]+)/\)\{\\sub $1\}/g;
        print $s;
}

# end of script


--
Patrick Gormley
Lapeer East High School
Lapeer MI 48446
http://chem.lapeer.org
---Lord, help me go the distance. I want to cross the finish line, not riding, or coasting, but running.



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