diff options
author | Karl Berry <karl@freefriends.org> | 2019-01-03 21:58:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-01-03 21:58:34 +0000 |
commit | db72269aba7977e4648acc3104c233ef2544cc1e (patch) | |
tree | c0ed956e4e991b9e36afe13bedc397b99d07c850 /Master/texmf-dist/metapost | |
parent | 9a6785706ed1238169de63236cf1ade3038a8315 (diff) |
mcf2graph (3jan19)
git-svn-id: svn://tug.org/texlive/trunk@49588 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 236 |
1 files changed, 144 insertions, 92 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index 3e9507270bc..09af723c895 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 4.34 Copyright (c) 2013-2018 Akira Yamaji +% mcf2graph ver 4.35 Copyright (c) 2013-2019 Akira Yamaji % % Permission is hereby granted, free of charge, to any person obtaining a copy of this software % and associated documentation files (the "Software"), to deal in the Software without restriction, @@ -22,20 +22,21 @@ % This package is located at : http://www.ctan.org/pkg/mcf2graph % Suggestion or request mail to : mcf2graph@gmail.com %---------------------------------------------------------------------------------------------- -% Set output no image file : mpost -s bboxmargin=0 FILENAME -% Set output first font only : mpost -s bboxmargin=1 FILENAME -% Set outputformat to "png" : mpost -s ahangle=1 FILENAME -% Set outputformat to "svg" : mpost -s ahangle=2 FILENAME -% Set outputformat to "eps" : mpost -s ahangle=3 FILENAME -% Set output aux file : mpost -s ahlength=1 FILENAME -% Set output report : mpost -s ahlength=2 FILENAME -% Set output MOL(V2000) : mpost -s ahlength=5 FILENAME -% Set output MOL(V3000) : mpost -s ahlength=6 FILENAME -% Set to use plain.mp label,arrow : mpost -s labeloffset=1 FILENAME -% Set to use plain.mp label,arrow,atom : mpost -s labeloffset=2 FILENAME +% Set output no image file : mpost -s bboxmargin=0 FILENAME +% Set output first font only : mpost -s bboxmargin=1 FILENAME +% Set outputformat to "eps"(.mps) : mpost -s ahangle=0 FILENAME +% Set outputformat to "png" : mpost -s ahangle=1 FILENAME +% Set outputformat to "svg" : mpost -s ahangle=2 FILENAME +% Set outputformat to "eps" (.eps) : mpost -s ahangle=3 FILENAME +% Set output aux file : mpost -s ahlength=1 FILENAME +% Set output report : mpost -s ahlength=2 FILENAME +% Set output MOL(V2000) : mpost -s ahlength=5 FILENAME +% Set output MOL(V3000) : mpost -s ahlength=6 FILENAME +% Set to use plain.mp (label,arrow) : mpost -s labeloffset=1 FILENAME +% Set to use plain.mp (label,arrow,atom) : mpost -s labeloffset=2 FILENAME %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tracingstats:=1; -message " This is mcf2graph ver 4.3 2018.11"; +message " This is mcf2graph ver 4.35 2019.01"; %------------------------------------------------------------------------------------------------- newinternal nA,nB,nC,nD,nE,nF,char_num,str_cnt,sub_usr,sub_int,tbl_cnt,sharp_char; numeric save_para[],comD[][],parD[][],cntD[],tbl_str_wd[],tbl_atom[],tbl_subst[][],tbl_atom_wt[], @@ -59,13 +60,18 @@ if (known green)and(known ahlength): mp_log_name:=jobname&"-info.aux"; prologues:=3; %-- default bboxmargin=2------------------------------------------------------------------ - if bboxmargin=0: def shipit = enddef; % No image file - elseif bboxmargin=1: proc_end:=1; % output first font only + if bboxmargin=0: def shipit = enddef; % No image file + elseif bboxmargin=1: proc_end:=1; % output first font only fi %--default ahangle=45--------------------------------------------------------------------- - if ahangle=1: outputformat:="png"; hppp:=vppp:=0.1; % png format - elseif ahangle=2: outputformat:="svg"; % svg format - elseif ahangle=3: outputformat:="eps"; % eps format(.eps) + if ahangle=0: outputformat:="eps"; % eps format(.mps) + elseif ahangle=1: outputformat:="png"; hppp:=vppp:=0.12; % png format(600dpi) + elseif ahangle=2: outputformat:="svg"; % svg format + elseif ahangle=3: outputformat:="eps"; % eps format(.eps) + % + elseif ahangle=11: outputformat:="png"; hppp:=vppp:=0.24; % png format(300dpi) + elseif ahangle=12: outputformat:="png"; hppp:=vppp:=0.10; % png format(720dpi) + elseif ahangle=13: outputformat:="png"; hppp:=vppp:=0.06; % png format(1200dpi) fi %--default ahlength=4--------------------------------------------------------------------- if ahlength=1: sw_aux_out:=1; % output aux @@ -153,9 +159,11 @@ enddef; vardef pic_c(expr i,s)= substring(i,i+1) of s enddef; %-------------------------------------------------------------------------------------------------- def store_par(text t)= - nA:=0; for list=t: if save_para[incr nA]<>list: save_para[nA]:=list; fi endfor enddef; -def restore_par(text t)= nA:=0; - forsuffixes list=t: if list<>save_para[incr nA]: list:=save_para[nA]; fi endfor enddef; + nA:=0; for list=t: nA:=nA+1; if save_para[nA]<>list: save_para[nA]:=list; fi endfor +enddef; +def restore_par(text t)= + nA:=0; forsuffixes list=t: nA:=nA+1; if list<>save_para[nA]: list:=save_para[nA]; fi endfor +enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def beginfont(text s)= char_num:=char_num+1; @@ -174,7 +182,7 @@ def beginfont(text s)= %------------------------------------------------------------------------------------------------ for i:=1 upto max_inf_num: info[i]:=":"; endfor f_ext:=inf_num:=cntM:=0; - for list=s: info[incr inf_num]:=list; endfor + for list=s: inf_num:=inf_num+1; info[inf_num]:=list; endfor enddef; %================================================================================================== def endfont= @@ -240,24 +248,36 @@ def set_def_MC= def **secondary n == (_postF,n) enddef; def */*secondary n == (_postG,n) enddef; enddef; %================================================================================================= -vardef '(text s)= ''(incr sub_usr)(s); sub_usr enddef; +vardef '(text TXT)= ''(incr sub_usr)(TXT); sub_usr enddef; %------------------------------------------------------------------------------------------------- -def ''(expr k)(text TXT)= +def ''(expr ADR)(text TXT)= begingroup if unknown inside_def_MC:: set_def_MC fi - cntD[k]:=0; + cntD[ADR]:=0; for list==TXT:: if known list:: - if pair list:: comD[k][incr cntD[k]]:=xpart(list); parD[k][cntD[k]]:=ypart(list); + if pair list:: + cntD[ADR]:=cntD[ADR]+1; + comD[ADR][cntD[ADR]]:=xpart(list); + parD[ADR][cntD[ADR]]:=ypart(list); elseif numeric list:: if list>=sub_emb_start:: for i==1 upto cntD[list]:: - comD[k][incr cntD[k]]:=comD[list][i]; parD[k][cntD[k]]:=parD[list][i]; + cntD[ADR]:=cntD[ADR]+1; + comD[ADR][cntD[ADR]]:=comD[list][i]; + parD[ADR][cntD[ADR]]:=parD[list][i]; endfor - else:: comD[k][incr cntD[k]]:=_mk_bond; parD[k][cntD[k]]:=list; + else:: + cntD[ADR]:=cntD[ADR]+1; + comD[ADR][cntD[ADR]]:=_mk_bond; + parD[ADR][cntD[ADR]]:=list; fi - elseif string list:: strD[incr str_cnt]:=list; - comD[k][incr cntD[k]]:=_set_atom; parD[k][cntD[k]]:=str_cnt; + elseif string list:: + str_cnt:=str_cnt+1; + strD[str_cnt]:=list; + cntD[ADR]:=cntD[ADR]+1; + comD[ADR][cntD[ADR]]:=_set_atom; + parD[ADR][cntD[ADR]]:=str_cnt; if pic_c(0,list)=="{":: tbl_str_wd[str_cnt]:=1.6; else:: tbl_str_wd[str_cnt]:=1; fi fi fi @@ -270,9 +290,11 @@ vardef '''(text TXT)= cntD[sub_int]:=0; for list==TXT:: cntD[sub_int]:=cntD[sub_int]+1; if numeric list:: - comD[sub_int][cntD[sub_int]]:=_numeric; parD[sub_int][cntD[sub_int]]:=list; + comD[sub_int][cntD[sub_int]]:=_numeric; + parD[sub_int][cntD[sub_int]]:=list; elseif pair list:: - comD[sub_int][cntD[sub_int]]:=xpart(list); parD[sub_int][cntD[sub_int]]:=ypart(list); + comD[sub_int][cntD[sub_int]]:=xpart(list); + parD[sub_int][cntD[sub_int]]:=ypart(list); fi endfor sub_int %------- Retern value ------- @@ -400,13 +422,13 @@ def ext(text TXT)= endgroup; enddef; %================================================================================================== -def ext_puts(expr a)(expr STR)= +def ext_puts(expr POS)(expr STR)= begingroup - save cp,sA,pC; + save cp,sA,pC,nB,nC; pair cp; string sA; picture pC; - cp:=a; + cp:=POS; nB:=defaultscale*defaultsize; nC:=0; %------------------------------------------------------------------------------------------------ @@ -435,6 +457,7 @@ def ext_puts(expr a)(expr STR)= enddef; %-------------------------------------------------------------------------------------------------- vardef label_emu@#(expr STR,POS) = %% modified 'thelabel@#(expr s,z)' of plain.mp + begingroup save oft,fx,fy,wds,sC,pC; pair oft,oft.lft,oft.rt,oft.top,oft.bot,oft.ulft,oft.llft,oft.urt,oft.lrt; string sC; @@ -461,6 +484,7 @@ vardef label_emu@#(expr STR,POS) = %% modified 'thelabel@#(expr s,z)' of plain.m oft.llft:=(-.7,-.7); fx.llft:=1; fy.llft:=1; oft.lrt:= ( .7,-.7); fx.lrt:=0; fy.lrt:=1; ext_puts(POS+(labeloffset*oft@#)-(wds*fx@#,defaultscale*defaultsize*fy@#))(STR); + endgroup enddef; %------------------------------------------------------------------------------------------------- vardef dotlabel_emu@#(expr STR,POS)= @@ -514,11 +538,11 @@ def sub_ext(expr c)(expr a,b)= fi enddef; %================================================================================================= -def MCa(expr FW,FH)(text s)= MCd(1,1)(FW,FH)(s) enddef; -def MCc(expr RW,RH)(text s)= MCd(RW,RH)(0.5,0.5)(s) enddef; -def MCf(text s)= MCd(1,1)(0.5,0.5)(s) enddef; +def MCa(expr FW,FH)(text TXT)= MCd(1,1)(FW,FH)(TXT) enddef; +def MCc(expr RW,RH)(text TXT)= MCd(RW,RH)(0.5,0.5)(TXT) enddef; +def MCf(text TXT)= MCd(1,1)(0.5,0.5)(TXT) enddef; %------------------------------------------------------------------------------------------------- -def MCd(expr RW,RH)(expr FW,FH)(text TX)= +def MCd(expr RW,RH)(expr FW,FH)(text TXT)= begingroup save com,par,adrA,adrB,f_bra,envT,envB,lenT,lineT,strAT,stkA,stkB,stkL,stkM,cntP,bondL,temp_len, temp_cntB,f_end,f_term,rotT,adrS,f_at,f_lineT,f_rotT,f_lenT,f_envT,angT,tempB,tempA, @@ -542,7 +566,7 @@ def MCd(expr RW,RH)(expr FW,FH)(text TX)= par_s:=ASCII("{"); par_e:=ASCII("}"); score_u:=ASCII("_"); hat:=ASCII("^"); cntA:=cntB:=cntP:=cntC:=0; strD[0]:=""; str_cnt:=2000; crR:=-ratio_chain_ring; %=============================================================================================== - ''(0)(TX,(_term,0)); + ''(0)(TXT,(_term,0)); proc_bond_atom(1); if (cntP>0)and(sw_subst_off=0): ps_get(1); fi char_use_check; @@ -569,7 +593,8 @@ def MCd(expr RW,RH)(expr FW,FH)(text TX)= %----------------------------------------------------------------------------------------------- sftX:=margin_left_right-minX+(font_wd-mol_wd-2margin_left_right)*FW; sftY:=margin_top_bottom-minY+(font_ht-mol_ht-2margin_top_bottom)*FH; - posM[0][incr cntM]:=(sftX,sftY); + cntM:=cntM+1; + posM[0][cntM]:=(sftX,sftY); posM[1][cntM]:=(minX+sftX,minY+sftY); posM[2][cntM]:=(max_x+sftX,max_y+sftY); wdM[cntM]:=mol_wd; @@ -587,7 +612,7 @@ enddef; %------------------------------------------------------------------------------------------------- def ps_put= if f_at=1: An:=getA(adrT); check_adrA(An); else: An:=cntA+1; fi - ps_adr[incr cntP]:=An; ps_com[cntP]:=par; op_cnt[cntP]:=0; + cntP:=cntP+1; ps_adr[cntP]:=An; ps_com[cntP]:=par; op_cnt[cntP]:=0; if lineT<>0: PO(_tmp_line,lineT) fi if rotT<>0: PO(_rot_ang,rotT) fi if lenT<>crR: PO(_chg_len,lenT) fi @@ -601,8 +626,8 @@ def ps_put= enddef; %------------------------------------------------------------------------------------------------- def ps_get(expr n)= - save sub_int; - sub_int:=0; nA:=cntP; nB:=cntD[0]; + sub_int:=0; + nA:=cntP; nB:=cntD[0]; for i=n upto cntP: PA(_jp_atom_abs,ps_adr[i]) PA(_push,1) for j=1 upto op_cnt[i]: PA(op_com[i][j],op_par[i][j]) endfor @@ -714,11 +739,11 @@ def proc_bond_atom(expr n)= for i=n upto cntD[0]: nC:=comD[0][i]; par:=parD[0][i]; if nC=_push: - if par=1: stkL[adrS]:=bondL; stkA[incr adrS]:=adrA:=cntA; stkB[adrS]:=adrB:=cntB; + if par=1: stkL[adrS]:=bondL; adrS:=adrS+1; stkA[adrS]:=adrA:=cntA; stkB[adrS]:=adrB:=cntB; elseif par=0: temp_len:=bondL; elseif par=2: stkA[adrS+1]:=cntA; stkB[adrS+1]:=cntB; fi - ef nC=_pop: if par=1: adrA:=stkA[decr adrS]; adrB:=stkB[adrS]; bondL:=stkL[adrS]; + ef nC=_pop: if par=1: adrS:=adrS-1; adrA:=stkA[adrS]; adrB:=stkB[adrS]; bondL:=stkL[adrS]; ef par=0: bondL:=temp_len; ef par=2: stkA[adrS+1]:=0; fi @@ -772,7 +797,8 @@ def proc_bond_atom(expr n)= enddef; %------------------------------------------------------------------------------------------------- def add_atom= - lineB[incr cntB]:=lineT; + cntB:=cntB+1; + lineB[cntB]:=lineT; lineT:=si; if lenT=crR: lenB[cntB]:=bondL; else: lenB[cntB]:=lenT; lenT:=crR; fi if f_bra=0: cntA:=cntA+1; sB[cntB]:=cntA; numS[cntA]:=strAT; @@ -800,7 +826,7 @@ def proc_skeleton= ef par=0: temp_len:=bondL; ef par=2: stkA[adrS+1]:=cntA; stkB[adrS+1]:=cntB; fi - ef nC=_pop: if par=1: adrA:=stkA[decr adrS]; adrB:=stkB[adrS]; envB:=stkM[adrS]; + ef nC=_pop: if par=1: adrS:=adrS-1; adrA:=stkA[adrS]; adrB:=stkB[adrS]; envB:=stkM[adrS]; ef par=0: temp_len:=bondL; ef par=2: stkA[adrS+1]:=0; fi @@ -827,8 +853,8 @@ def proc_skeleton= endfor enddef; %------------------------------------------------------------------------------------------------- -def add_bond(expr m)= - if m=_arg_ang: nA:=proc_env(angT,envB,60,-60); else: nA:=m; fi +def add_bond(expr ROT)= + if ROT=_arg_ang: nA:=proc_env(angT,envB,60,-60); else: nA:=ROT; fi if f_bra=0: adrT:=cntA:=cntA+1; posA[cntA]:=posBs; angA[cntA]:=angT; if nA>=0: ang_br[cntA]:=angT+nA/2-90; else: ang_br[cntA]:=angT+nA/2+90; fi @@ -848,12 +874,12 @@ def add_bond(expr m)= cntB:=cntB+1; posBs:=posBe; enddef; %================================================================================================== -vardef getA(expr n)= - if n>=0: stkA[adrS+1]+n ef n>=-999: cntA+n+1 else: stkA[adrS]+n+4095 fi +vardef getA(expr ADR)= + if ADR>=0: stkA[adrS+1]+ADR ef ADR>=-999: cntA+ADR+1 else: stkA[adrS]+ADR+4095 fi enddef; %-------------------------------------------------------------------------------------------------- -vardef getB(expr n)= - if n>=1: stkB[adrS+1]+n ef n=0: tempB ef n>=-999: cntB+n+1 else: stkB[adrS]+n+4095 fi +vardef getB(expr ADR)= + if ADR>=1: stkB[adrS+1]+ADR ef ADR=0: tempB ef ADR>=-999: cntB+ADR+1 else: stkB[adrS]+ADR+4095 fi enddef; %-------------------------------------------------------------------------------------------------- def termA= @@ -875,22 +901,33 @@ def termB= fi enddef; %-------------------------------------------------------------------------------------------------- -def proc_cyc(expr n)= add_bond(angle(posA[n]-posBs)-angT); enddef; +def proc_cyc(expr ADR)= add_bond(angle(posA[ADR]-posBs)-angT); enddef; %-------------------------------------------------------------------------------------------------- -def glu_c(expr n)= if numS[n]<>0: nB:=angT mod 90; nC:=.5tbl_str_wd[numS[n]]*atom_wd; - if nB<45: glu:=glu+((sind(nB)*nC)++nC); - else: glu:=glu+((cosd(nB)*.5atom_wd)++.5atom_wd) fi fi enddef; +def glu_c(expr NUM)= + if numS[NUM]<>0: + nB:=angT mod 90; + nC:=0.5tbl_str_wd[numS[NUM]]*atom_wd; + if nB<45: glu:=glu+((sind(nB)*nC)++nC); + else: glu:=glu+((cosd(nB)*.5atom_wd)++.5atom_wd); + fi + fi +enddef; %-------------------------------------------------------------------------------------------------- -vardef proc_env(expr n,m,a,b)= r:=(n mod 360); - if m>=sub_emb_start: parD[m][cntB-temp_cntB] else: - if m=hz:if r=0:a ef r<=90:b ef r<=180:a ef r<270:b else:a fi - ef m=vt:if r=0:b ef r<90:a ef r<=180:b ef r<=271:a else:b fi - ef (m>=-180)and(m<=180): m fi fi +vardef proc_env(expr ANG,ENV,CCW,CWS)= + nA:=(ANG mod 360); + if ENV>=sub_emb_start: + parD[ENV][cntB-temp_cntB] + else: + if ENV=hz: if nA=0:CCW ef nA<=90:CWS ef nA<=180:CCW ef nA<270:CWS else:CCW fi + ef ENV=vt: if nA=0:CWS ef nA<90:CCW ef nA<=180:CWS ef nA<=271:CCW else:CWS fi + ef (ENV>=-180)and(ENV<=180): ENV + fi + fi enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def draw_atom(expr NUM,POS,ANG,STR,WD)= begingroup - save pA,pT,dx,pC,nE,nC; + save pA,pT,pC,sB,dx,nB,nC,nE; string sB; pair pA,pT; picture pC; @@ -937,7 +974,7 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def draw_bond(expr NN,BP,EP,ANG,LN)= begingroup - save ww,ap,am,hpt,Ls,Le,pA,pB,pC,pT,nL,nC; + save ww,ap,am,hpt,Ls,Le,pA,pB,pC,pT,nB,nC,nL; pair Ls,Le; path pA,pB,pC,pT; %---------------------------------------------------------------------------------------------- @@ -1058,7 +1095,7 @@ NHiPr:=NHMe!:='(NH,!,iPr); NHtBu:='(NH,!,tBu); NHMe:=NH!:='(NH,!); NHEt:=NH!2:=' !?3:='(!,?3); !?4:='(!,?4); !?5:='(!,?5); !?6:='(!,?6); CF2:='(/F,60,F); CCl2:='(/Cl,60,Cl); CBr2:='(/Br,60,Br); CF3:='(/F,/F^60,60,F); CCl3:='(/Cl,/Cl^60,60,Cl); CBr3:='(/Br,/Br^60,60,Br); %================================================================================================== -nA:=0; for list=parameter_list: save_para[incr nA]:=list; endfor +nA:=0; for list=parameter_list: nA:=nA+1; save_para[nA]:=list; endfor %-------------------------------------------------------------------------------------------------- %%%%%%message "count of sub_usr =" & decimal(sub_usr); %-------------------------------------------------------------------------------------------------- @@ -1068,24 +1105,27 @@ def expand_set= !NH2:='(!,NH2); !CHO:='(!,CHO); !COOH:='(!,COOH); !CN:='(!,CN); !SH:='(!,SH); !NO2:='(!,NO2); enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -def char_size_set(expr a)(expr b)(expr s)= - for j=0 upto length(s)-1: nA:=ASCII(pic_c(j,s)); - tbl_char_wd[nA]:=a; tbl_char_ht[nA]:=b; +def char_size_set(expr WD)(expr HT)(expr STR)= + for j=0 upto length(STR)-1: + nA:=ASCII(pic_c(j,STR)); + tbl_char_wd[nA]:=WD; + tbl_char_ht[nA]:=HT; endfor enddef; -%--------------------------------------------------------------- -char_size_set( 1)( 1)("CGHMNOQ"); -char_size_set(.9)( 1)("ABDEFIJKLPRSTUVWXYZ/><m"); -char_size_set(.7)( 1)(" ()[]0123456789nhj=_tfgpq"); -char_size_set(.7)(.7)("-+*"); +%------------------------------------------------------------------------------------------------- +char_size_set( 1)( 1)("CGHMNOQ"); +char_size_set( .9)( 1)("ABDEFIJKLPRSTUVWXYZ/><m"); +char_size_set( .7)( 1)(" ()[]0123456789nhj=_tfgpq"); +char_size_set( .7)( .7)("-+*"); char_size_set(.45)(.95)("l"); -char_size_set(.75)(.8)("o"); -char_size_set(.8)(.8)("e"); -char_size_set(.7)(.8)("abdcksuvxzwry"); -char_size_set(.35)(.9)("i"); -char_size_set(.4)( 1)(".,:;'`^"); +char_size_set(.75)( .8)("o"); +char_size_set( .8)( .8)("e"); +char_size_set( .7)( .8)("abdcksuvxzwry"); +char_size_set(.35)( .9)("i"); +char_size_set( .4)( 1)(".,:;'`^"); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def draw_char(expr CHR,POS,WD,PEN,NUM)= +begingroup save Z,aW,aH,fW,fH,hW,hW,hH,fP,hP,pathO,pathOh,pos,dw,dwh,dwv,cdw,ppcs,sbp,sC; path pathO,pathOh; string sC; @@ -1199,6 +1239,7 @@ ef sC="+": dwv Z19--Z14; dwh Z09--Z10; ef sC="*": dw Z19--Z14; dw Z09--Z10; dw (.2aW,.2aH)--(.8aW,.8aH); dw (.2aW,.8aH)--(.8aW,.2aH); else: fi +endgroup enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def blank_str:= " " enddef; @@ -1215,21 +1256,27 @@ def bond_check(expr a)(text s)= fi enddef; %-------------------------------------------------------------------------------------------------- -vardef stripP(expr a)= - if length(a)=4: substring (1,3) of a - elseif length(a)=6: substring (1,2) of a - else: a +vardef stripP(expr ATOM)= + if length(ATOM)=4: substring (1,3) of ATOM + elseif length(ATOM)=6: substring (1,2) of ATOM + else: ATOM fi enddef; %================================================================================================== -def STa(expr a,b,c)= - tbl_atom_str[incr tbl_cnt]:=a; tbl_atom[tbl_cnt]:=0; - tbl_atom_wt[tbl_cnt]:=b; tbl_atom_mi[tbl_cnt]:=c; +def STa(expr ATOM,WT,MI)= + tbl_cnt:=tbl_cnt+1; + tbl_atom_str[tbl_cnt]:=ATOM; + tbl_atom[tbl_cnt]:=0; + tbl_atom_wt[tbl_cnt]:=WT; + tbl_atom_mi[tbl_cnt]:=MI; enddef; %---------------------------------------------------------------------------------- -def STb(expr a)(text s)= - tbl_atom_str[incr tbl_cnt]:=a; tbl_atom[tbl_cnt]:=0; - for list=s: tbl_atom[tbl_cnt]:=tbl_atom[tbl_cnt]+1; +def STb(expr ATOM)(text TXT)= + tbl_cnt:=tbl_cnt+1; + tbl_atom_str[tbl_cnt]:=ATOM; + tbl_atom[tbl_cnt]:=0; + for list=TXT: + tbl_atom[tbl_cnt]:=tbl_atom[tbl_cnt]+1; for j=1 upto tbl_cnt: if list=tbl_atom_str[j]: tbl_subst[tbl_cnt][tbl_atom[tbl_cnt]]:=j; fi endfor @@ -1319,9 +1366,12 @@ def proc_calc_out= sumA[2]:=sumA[2]+cnt_hide_H; for i=1 upto tbl_cnt: if sumA[i]>=1: - nA:=tbl_atom_wt[i]/100*sumA[i]; MWp:=MWp+nA; - if (MWp<40)and(nA<40): MW_num:= MW_num+tbl_atom_wt[i]*sumA[i]; - MI_num:= MI_num+tbl_atom_mi[i]*sumA[i]; fi + nA:=tbl_atom_wt[i]/100*sumA[i]; + MWp:=MWp+nA; + if (MWp<40)and(nA<40): + MW_num:= MW_num+tbl_atom_wt[i]*sumA[i]; + MI_num:= MI_num+tbl_atom_mi[i]*sumA[i]; + fi cal_FM:=cal_FM&stripP(tbl_atom_str[i]) if sumA[i]>=2: &decimal(sumA[i]) fi; fi endfor @@ -1410,6 +1460,7 @@ def proc_report_out= enddef; %================================================================================================== def proc_mol_out= + begingroup save chg_cnt,chg_atm,chg_chg; numeric chg_atm,chg_chg; chg_cnt:=0; @@ -1463,6 +1514,7 @@ def proc_mol_out= printf "M V30 END CTAB"; printf "M END"; fi + endgroup enddef; %------------------------------------------------------------------------------------------------- vardef fit_zero(expr n)=if n<=9: "00" elseif n<=99: "0" fi enddef; |