\START92\ \COMMENT= \NAME=chem \FILE=CHEM.89F (str) Func \(C)\str:Func Local l1,temp,temp2,temp3,temp4 If str="e-" or str="e\(-)\":Return \alpha\e\alpha\ 0\->\temp While dim(str)>0 left(str,1)\->\l1 If l1\>=\"A" and l1\<=\"Z" or l1="+" or l1="-" or l1="\(-)\" Then If l1\>=\"A" and l1\<=\"Z" Then If mid(str,2,1)\>=\"a" and mid(str,2,1)\<=\"z" Then If mid(str,3,1)\>=\"a" and mid(str,3,1)\<=\"z" Then #("\alpha\"&left(str,3)&"\alpha\")\->\temp2 mid(str,4)\->\str Else #("\alpha\"&left(str,2)&"\alpha\")\->\temp2 mid(str,3)\->\str EndIf Else #("\alpha\"&l1&"\alpha\")\->\temp2 mid(str,2)\->\str EndIf ElseIf l1="+" Then \(-)\\alpha\e\alpha\\->\temp2 mid(str,2)\->\str ElseIf l1="-" or l1="\(-)\" Then \alpha\e\alpha\\->\temp2 mid(str,2)\->\str EndIf For temp3,1,dim(str) mid(str,temp3,1)\->\temp4 If (temp4<"0" or temp4>"9") and temp4\!=\".":Exit EndFor If temp3=1 Then temp+temp2\->\temp Else temp+temp2*expr(left(str,temp3-1))\->\temp mid(str,temp3)\->\str EndIf ElseIf l1="(" Then 1\->\temp4 For temp3,2,dim(str) If mid(str,temp3,1)="(":temp4+1\->\temp4 If mid(str,temp3,1)=")":temp4-1\->\temp4 If temp4=0:Exit EndFor If temp4\!=\0:Return "Syntax Error!" chem(mid(str,2,temp3-2))\->\temp2 mid(str,temp3+1)\->\str For temp3,1,dim(str) mid(str,temp3,1)\->\temp4 If (temp4<"0" or temp4>"9") and temp4\!=\".":Exit EndFor If temp3=1 Then temp+temp2\->\temp Else temp+temp2*expr(left(str,temp3-1))\->\temp EndIf mid(str,temp3)\->\str ElseIf l1="^" or l1=" " Then mid(str,2)\->\str left(str,1)\->\l1 If l1="+" or l1="-" or l1="\(-)\":Cycle If (l1<"0" or l1>"9") and l1\!=\".":Return "Syntax error!" For temp3,2,dim(str) mid(str,temp3,1)\->\temp4 If (temp4<"0" or temp4>"9") and temp4\!=\".":Exit EndFor expr(left(str,temp3-1))\->\temp2 mid(str,temp3)\->\str left(str,1)\->\l1 If l1="+" Then temp-temp2*\alpha\e\alpha\\->\temp mid(str,2)\->\str ElseIf l1="-" or l1="\(-)\" Then temp+temp2*\alpha\e\alpha\\->\temp mid(str,2)\->\str Else temp-temp2*\alpha\e\alpha\\->\temp EndIf Else Return "Syntax Error!" EndIf EndWhile Return temp EndFunc \STOP92\