summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-01-03 21:17:41 +0000
committerKarl Berry <karl@freefriends.org>2024-01-03 21:17:41 +0000
commit4e133974f45cb502995930cec2e1390716097ff6 (patch)
tree3d61ea22a4b5751973bb3ee5cfadec8f3b6c8967 /Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp
parent4487110af8bd773d95405e8873af6922eb5f78c8 (diff)
mcf2graph (3jan24)
git-svn-id: svn://tug.org/texlive/trunk@69281 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp')
-rw-r--r--Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp1101
1 files changed, 562 insertions, 539 deletions
diff --git a/Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp b/Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp
index cf2eb5683f7..cffbaa6fe6e 100644
--- a/Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp
+++ b/Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp
@@ -1,5 +1,5 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% mcf2graph ver 5.02 Copyright (c) 2013-2023 Akira Yamaji
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% mcf2graph ver 5.10 Copyright (c) 2013-2024 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,
@@ -15,71 +15,64 @@
% AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
% DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%-------------------------------------------------------------------------------------------------
% mcf2graph is MetaPost macro package convert Molecular Coding Format(MCF) to graphic file
% sgv/eps/png/mdl molfile
-%--------------------------------------------------------------------------------------------------
+%-------------------------------------------------------------------------------------------------
% This package is located at : http://www.ctan.org/pkg/mcf2graph
% Suggestion or request mail to : mcf2graph@gmail.com
-%--------------------------------------------------------------------------------------------------
-% Set outputformat to "svg" (.svg) : mpost FILENAME *default
-% Set outputformat to "png" (.png) : mpost -s ahangle=1 FILENAME
-% Set outputformat to "eps" (.eps) : mpost -s ahangle=2 FILENAME
-% Set outputformat to "eps" (.mps) : mpost -s ahangle=3 FILENAME
-% Set output MOL file (V2000) : mpost -s ahlength=5 FILENAME
-% Set output MOL file (V3000) : mpost -s ahlength=6 FILENAME
-% Set output report : mpost -s ahlength=7 FILENAME
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-message "* This is mcf2graph ver 5.02 2023.05.28";
+message "* This is mcf2graph ver 5.10 2024.01.03";
tracingstats:=1; prologues:=3; warningcheck:=0;
%-------------------------------------------------------------------------------------------------
newinternal string EN_;
-numeric save_num[],parts_com[][],parts_par[][],parts_cnt[],tbl_atom[],tbl_group[][],tbl_atom_wt[],
+numeric save_num[],pcode_com[][],pcode_par[][],pcode_cnt[],tbl_atom[],tbl_group[][],tbl_atom_wt[],
tbl_atom_mi[],tbl_char_wd[],tbl_char_ht[],at_char[],mc_indent[],op_indent[],ex_indent[],
- ad_indent[],unit_lines[],info[];
-string row[][],save_str[],tbl_atom_str[],str_tbl[],arg_s[],mc[],ex[],ad[],op[],tag[],
- lib_tag[][],lib_val[][],mc,ex,ad,op,aux_delimiter,default_library,sC,sI,sS,sT,sV,
- EN,FM,MW,MI,CAT,JN,CAS,USE,EXA,EXB,
- file_input,file_output,default_temp_file,mpfont,atomfont,tempc,temps,blanks;
+ ad_indent[],unit_lines[],info[],tbl_asc[],lenw[];
+string row[][],save_str[],tbl_atom_str[],str_tbl[],arg_s[],mc[],ex[],ad[],op[],tag[],rw[],
+ lib_tag[][],lib_val[][],mc,ex,ad,op,aux_delimiter,default_library,EN,FM,MW,MI,CAT,JN,CAS,
+ USE,EXA,EXB,file_input,file_output,default_temp_file,mpfont,atomfont,tempc,temps,blanks,
+ sC,sI,sS,sT,sV,forbiddens;
pair save_pair[],msize,mposition,fsize,fmargin,dum,save_mposition;
%-------------------------------------------------------------------------------------------------
-fig_num:=str_cnt:=tbl_cnt:=mangle:=sw_expand:=sw_frame:=sw_trimming:=sw_ext_all:=sw_abbreviate:=0;
-sw_comment:=sw_output:=sw_numbering:=tag_cnt:=0; numbering_start:=1; numbering_end:=4095;
+fig_num:=str_cnt:=tbl_cnt:=mangle:=sw_frame:=sw_trimming:=sw_ext_all:=sw_abbreviate:=sw_expand:=0;
+sw_comment:=sw_output:=sw_numbering:=tag_cnt:=rw_cnt:=pcode_all:=0;
+numbering_start:=1; numbering_end:=4095;
%-------------------------------------------------------------------------------------------------
-aux_delimiter:=";"; blanks:= " "; dum:=(-4091,0);
+aux_delimiter:=";"; blanks:= " "; forbiddens:=" &()[]{}^=;!'+,`~"; dum:=(-4091,0);
for s="No","EN","JN","MW","MI","FM","CAT","CAS","USE","EXA","EXB": tag[incr tag_cnt]:=s; endfor
-Fig:=1; Mcode:=2; Calc:=4; Info:=8; Table:=16; Report:=32; MOL2k:=64; MOL3k:=128;
+MW_n:=0; Fig:=1; Mcode:=2; Calc:=4; Info:=8; Table:=16; Report:=32; MOL2k:=64; MOL3k:=128;
Atom:=8; Bond:=16; Group:=32; Mol:=64; Outside:=1; Inside:=2; Bothside:=Outside+Inside;
%-------------------------------------------------------------------------------------------------
-a_prn_s:=ASCII("("); a_prn_e:=ASCII(")"); a_brc_s:=ASCII("{"); a_brc_e:=ASCII("}");
-a_brk_s:=ASCII("["); a_brk_e:=ASCII("]"); a_cmm:=ASCII(","); a_equ:=ASCII("=");
-a_ast:=ASCII("*"); a_sls:=ASCII("/"); a_gtn:=ASCII("<"); a_ltn:=ASCII(">"); a_and:=ASCII("&");
-a_dol:=ASCII("$"); a_hsh:=ASCII("#"); a_hat:=ASCII("^"); a_tld:=ASCII("~"); a_bqt:=ASCII("`");
-a_cln:=ASCII(":"); a_amk:=ASCII("@"); a_zero:=ASCII("0"); a_nine:=ASCII("9"); a_qut:=ASCII("'");
-a_bar:=ASCII("|"); a_plus:=ASCII("+"); a_minus:=ASCII("-");
+PRS:=ASCII("(");PRE:=ASCII(")");BRS:=ASCII("{");BRE:=ASCII("}");BKS:=ASCII("[");BKE:=ASCII("]");
+CMA:=ASCII(",");EQU:=ASCII("=");AST:=ASCII("*");SLS:=ASCII("/");GTN:=ASCII("<");LTN:=ASCII(">");
+AMP:=ASCII("&");HSH:=ASCII("#");HAT:=ASCII("^");TLD:=ASCII("~");BQT:=ASCII("`");CLN:=ASCII(":");
+AMK:=ASCII("@");QUT:=ASCII("'");BAR:=ASCII("|");PLS:=ASCII("+");MIS:=ASCII("-");BLK:=ASCII(" ");
+BSL:=ASCII("\");QES:=ASCII("?");
+%-------------------------------------------------------------------------------------------------
+for s="??!","!?!","!!!","!?","?!","??","*/*","/*","*/","//","**","##","||","\\":
+ rw[incr rw_cnt]:=s; lenw[rw_cnt]:=length(s); endfor
%-------------------------------------------------------------------------------------------------
let DIV= /; let MUL= *; let LT= <; let GT= >; let AND= &; let :: = : ; let == = =; let ef=elseif;
-let ISP=intersectionpoint; def ]]]=] ] ] enddef;
+let ISP=intersectionpoint; def ]]]=] ] ] enddef; let +++ = ++; let +- = +;
%-------------------------------------------------------------------------------------------------
def ext(text t)= sw_ext_all:=1; def EXT_ALL = t enddef; enddef;
def ext_clear= sw_ext_all:=0; def EXT_ALL = enddef; enddef;
+def wpcs expr n= withpen pencircle scaled n enddef;
+def ppcs expr n= pickup pencircle scaled n enddef;
+def sbp(expr m,n)expr p=subpath(m*length(p),n*length(p)) of p enddef;
+def printf expr s= write s to file_output enddef;
+def warning(expr s)= message "% "&decimal(fig_num)&fdr(3)(incr warning_cnt)&")"&s; enddef;
%-------------------------------------------------------------------------------------------------
vardef frac primary n= n-floor n enddef;
vardef iif(expr a,b,c)=if a: b else: c fi enddef;
vardef subc(expr i,s)= substring(i-1,i) of s enddef;
vardef sfrt(expr a,b,c)= a shifted ((b,0) rotated c) enddef;
-%-------------------------------------------------------------------------------------------------
-def wpcs expr n= withpen pencircle scaled n enddef;
-def ppcs expr n= pickup pencircle scaled n enddef;
-def sbp(expr m,n)expr p=subpath(m*length(p),n*length(p)) of p enddef;
-%-------------------------------------------------------------------------------------------------
vardef fsr(expr n)(expr s)= (substring(0,n-length(s)) of blanks)&s enddef;
vardef fsl(expr n)(expr s)= s&(substring(0,n-length(s)) of blanks) enddef;
vardef fdr(expr n)(expr s)=
if length(decimal(s))>n: substring (0,n) of decimal(s) else: fsr(n)(decimal(s)) fi enddef;
vardef fdl(expr n)(expr s)= fsl(n)(decimal(s)) enddef;
-def printf expr s= write s to file_output enddef;
-def warning(expr s)= message "% "&decimal(fig_num)&fdr(3)(incr warning_cnt)&")"&s; enddef;
%=================================================================================================
default_library:="main_lib.mcf"; default_temp_file:="temp.mcf";
mpfont:="uhvr8r"; atomfont:="draw"; defaultfont:=mpfont;
@@ -91,16 +84,17 @@ ef ahangle=3: outputformat:="eps"; % eps format(.mps)
ef ahangle=45: outputformat:="svg"; % svg format *default
fi
%--default ahlength=4---------------------------------------------------------------------
-if ahlength=4: sw_output:=Fig; % output figure *default
-ef ahlength=5: sw_output:=MOL2k; % output MOL(V2000)
-ef ahlength=6: sw_output:=MOL3k; % output MOL(V3000)
+if ahlength=3: sw_output:=Fig; sw_expand:=1; % output figure(expanded)
+ef ahlength=4: sw_output:=Fig; % output figure *default
+ef ahlength=5: sw_output:=MOL2k; sw_expand:=1; % output MOL(V2000)
+ef ahlength=6: sw_output:=MOL3k; sw_expand:=1; % output MOL(V3000)
ef ahlength=7: sw_output:=Report; % output report
fi
%-- default bboxmargin=2------------------------------------------------------------------
if bboxmargin=3: ext(defaultfont:=mpfont; defaultscale:=.3; label.rt(EN,(0,0));)
ef bboxmargin=4: sw_output:=Fig+Calc;
ext(defaultfont:=mpfont; defaultscale:=.3;
- label.rt(EN&" / "&MW&" / "&decimal(num_MW-scantokens(MW)),(0,0));) fi
+ label.rt(EN&" / "&MW&" / "&decimal(MW_n-scantokens(MW)),(0,0));) fi
%--default outputtemplate:="%j-%3c."&"svg"------------------------------------------------
if outputformat="svg": outputtemplate:="s%3c-%{EN_}.svg";
ef outputformat="png": outputtemplate:="p%3c-%{EN_}.png";
@@ -113,8 +107,7 @@ message "* outputformat="&outputformat;
message "* outputtemplate="&outputtemplate;
if ahlength=5: message "* output MOL file(V2000)"; message "* "&jobname&"-nnn-"&"EN"&".mol";
ef ahlength=6: message "* output MOL file(V3000)"; message "* "&jobname&"-nnn-"&"EN"&".mol";
-ef ahlength=7: message "* output report file"; message "* file name="&jobname&"-report.txt";
-fi
+ef ahlength=7: message "* output report file"; message "* file name="&jobname&"-report.txt"; fi
clearit;
%--------------------------------------------------------------------------------------------------
?3:=?20:=Ph:=Ph1:=Ph2:=hz:=0; vt:=1;
@@ -124,17 +117,15 @@ ratio_hashgap_bond:=0.12; ratio_hash_black:=0.4; ratio_wedge_bond:=0.12; ratio_a
offset_thickness:=0.2; offset_bond_gap:=0.3; offset_hash_gap:=0.1; offset_atom:=0.8;
offset_wedge:=0.4; thickness_frame:=0.2;
max_blength:=10mm; blength:=mangle:=0; max_labelsize:=20mm; dottedline_gap:=1.5;
-%--------------------------------------------------------------------------------------------------
fsize:=(30mm,20mm); fmargin:=(0.4mm,0.4mm); msize:=(1,1); mposition:=(0.5,0.5);
-%=== bboxmargin:=0; % 2bp => 0 ====================================================================
ahangle:=45; ahlength:=4; defaultsize:=8; defaultscale:=1; labeloffset:=3; ext_defaultline:=0.5;
-outputformatoptions:="";
lonepairdiam:=lonepairspace:=circlediam:=circlepen:=bboxmargin:=0; mc_length:=100;
+outputformatoptions:="";
%==================================================================================================
-parts_emb_start:=1000; % 1001 => 2000 for embedded parts (max 1900)
-parts_emi_start:=1900; % 1901 => 2000 for embedded internal parts (max 100)
-parts_usr_start:=2000; % 2001 => 3000 for user parts (max 1000)
-parts_int_start:=3000; % 3001 => 4000 for internal parts (max 1000)
+pcode_emb_start:=1000; % 1001 => 1900 for embedded pcode (max 1900)
+pcode_emi_start:=1900; % 1901 => 2000 for embedded internal pcode (max 100)
+pcode_usr_start:=2000; % 2001 => 3000 for user pcode (max 1000)
+pcode_int_start:=3000; % 3001 => 4000 for internal pcode (max 1000)
%--------------------------------------------------------------------------------------------------
def def_com(expr n)(text tx)= nA:=n; forsuffixes list=tx:: list:=nA; nA:=nA+1; endfor enddef;
def_com(-4090)(_com,_jp_atom,_jp_absA,_jp_bond,_cyc,_cyc_sB,_cyc_eB,_set_line,_tmp_line,_chg_len,
@@ -142,8 +133,8 @@ def_com(-4090)(_com,_jp_atom,_jp_absA,_jp_bond,_cyc,_cyc_sB,_cyc_eB,_set_line,_t
_group_si,_group_dm,_group_wf,_group_zf,_set_adr,_mk_bond,_set_atom,_arrange_ang,_chg_atom,
_tmp_rot,_fuse,_size_atom,_numeric,_jump_at,_set_add,_chg_add,_nop,_mark,_moff,_term,_len_s,
_len_e,_len_ss,_len_ee,_group_s,_group_e,_rest,_charge,_from,_until,
- si,dl,dl_,dr,dr_,db,dm,dm_,tm,wf,wb,bd,bz,zf,zb,dt,wv,nl,vf,vb,nb,wf_r,wb_r,bd_r,
- arc_lb,arc_br,arc_lbr,arc_ltr,si_,wf_,wb_,zf_,zb_,wv_,bd_);
+ si,dl,dl_,dr,dr_,db,dm,dm_,tm,wf,wb,bd,bz,zf,zb,dt,wv,nl,vf,vb,nb,wf_r,wb_r,bd_r,arc_lb,arc_br,
+ arc_lbr,arc_ltr,si_,wf_,wb_,zf_,zb_,wv_,bd_);
%--------------------------------------------------------------------------------------------------
def parameter_list=
sw_numbering,sw_expand,sw_output,sw_ext_all,sw_frame,sw_trimming,sw_abbreviate,ratio_atom_bond,
@@ -151,31 +142,37 @@ def parameter_list=
ratio_hashgap_bond,ratio_thickness_char,ratio_wedge_bond,ratio_atomgap_atom,lonepairdiam,
lonepairspace,offset_atom,offset_wedge,max_blength,offset_hash_gap,offset_bond_gap,
thickness_frame,offset_thickness,numbering_start,numbering_end,defaultsize,defaultscale,
- labeloffset,mangle,blength,fsize,fmargin,msize,mposition,defaultfont,atomfont,dottedline_gap,
- Me,Et,CH3,NH,NH2,NO,NO2,OH,CHO,COOH,CN,SH,!CH3,!NH2,!NO2,!OH,!CHO,!COOH,!CN,!SH enddef;
+ labeloffset,mangle,blength,fsize,fmargin,msize,mposition,defaultfont,atomfont,dottedline_gap
+enddef;
%--------------------------------------------------------------------------------------------------
def init_par(text t)= nA:=nB:=nC:=0;
for list=t: if numeric list: save_num[incr nA]:=list;
ef pair list: save_pair[incr nB]:=list;
- ef string list: save_str[incr nC]:=list; fi endfor enddef;
+ ef string list: save_str[incr nC]:=list;
+ fi
+ endfor
+enddef;
%--------------------------------------------------------------------------------------------------
def store_par(text t)= nA:=nB:=nC:=0;
for list=t: if numeric list: if save_num[incr nA]<>list: save_num[nA]:=list; fi
ef pair list: if save_pair[incr nB]<>list: save_pair[nB]:=list; fi
- ef string list: if save_str[incr nC]<>list: save_str[nC]:=list; fi fi endfor
+ ef string list: if save_str[incr nC]<>list: save_str[nC]:=list; fi
+ fi
+ endfor
enddef;
%--------------------------------------------------------------------------------------------------
def restore_par(text t)= nA:=nB:=nC:=0;
forsuffixes list=t: if numeric list: if list<>save_num[incr nA]: list:=save_num[nA]; fi
ef pair list: if list<>save_pair[incr nB]: list:=save_pair[nB]; fi
- ef string list: if list<>save_str[incr nC]: list:=save_str[nC]; fi fi
+ ef string list: if list<>save_str[incr nC]: list:=save_str[nC]; fi
+ fi
endfor
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def beginfigm=
begingroup
- save ','',//,@,#,#@,##,\,\\,\*,|=,|<,**,_,f_ext,blen,ext,add,ang_br,fw_n,bw_n,at_colon,at_dot,
- info_cnt,group_cnt,bond_cntA,firstc,warning_cnt,hideH,hideH_cnt,cntM,cntA,cntB,
+ save ','',//,@,#,#@,##,\,\\,\*,|=,|<,**,++,_,f_ext,blen,ext,add,ang_br,fw_n,bw_n,
+ info_cnt,bond_cntA,firstc,warning_cnt,hideH,hideH_cnt,cntM,cntA,cntB,
minX,minY,maxX,maxY,posA,posM,lineB,sB,eB,angB,angA,lenB,angX,numS,sumA,bond_num,wdM,htM,
chargeA,addA,add_rot,mol_pic,color_list,filter_s,no,mw,mi,fm;
numeric hideH[],lineB[],sB[],eB[],angB[],angA[],lenB[],angX[],strA[],sumA[],bond_num[],
@@ -188,20 +185,19 @@ def beginfigm=
store_par(parameter_list);
no:=mc:=ex:=ad:=op:=temps:=mw:=mi:=fm:=filter_s:="";
EN:=JN:=MW:=FM:=MI:=CAS:=CAT:=EXA:=EXB:=USE:="-";
- f_ext:=cntM:=mc_row:=ex_row:=ad_row:=op_row:=info_cnt:=0;
- let ext=ext_to_fig; let add=add_to_molecule;
+ f_ext:=cntM:=mc_row:=ex_row:=ad_row:=op_row:=info_cnt:=err_cnt:=0;
+ let ext=ext_to_fig; let add=add_to_molecule; let ++=add_to_molecule; let **=ext_to_fig;
def ' = read_ud enddef; def '' = readm enddef; def \ = drawm enddef; def \\ = putm enddef;
def \* = checkm enddef; def $ = getm enddef; def @ expr p = mposition:=p; enddef;
def # expr p = fsize:=p; enddef; def #@ expr p = fmargin:=p; enddef;
def ## expr p = msize:=p; enddef; def |=(expr n) = blength:=n; enddef;
def |<(expr n) = max_blength:=n; enddef; def _ expr s = EN:=s; enddef;
- parts_num:=parts_usr_start; parts_int:=parts_int_start;
- fig_num:=fig_num+1;
+ pcode_num:=pcode_usr_start; pcode_int:=pcode_int_start; fig_num:=fig_num+1;
mol_pic[0]:=nullpicture;
enddef;
%--------------------------------------------------------------------------------------------------
def endfigm=
- %---------------------------------------------------------------------------------------------
+ %--------------------------------------------------------------------------------------------
if cntM>=1:
%--------------------------------------------------------------------------------------------
if scan_bit(sw_output,Fig):
@@ -224,8 +220,7 @@ def endfigm=
fi
%----------------------------------------------------------------------------------------
if scan_bit(sw_frame,Outside): draw_frame((0,0),fsize,thickness_frame);
- else: draw_corner(fsize,0.004);
- fi
+ else: draw_corner(fsize,0.004); fi
if scan_bit(sw_frame,Inside): draw_frame(fmargin,fsize-2fmargin,thickness_frame); fi
for i=1 upto cntM:
addto currentpicture also mol_pic[i] shifted posM[0][i]; mol_pic[i]:=nullpicture;
@@ -241,27 +236,25 @@ def endfigm=
if scan_bit(sw_output,MOL2k): proc_mol_out(2000); fi
if scan_bit(sw_output,MOL3k): proc_mol_out(3000); fi
%---------------------------------------------------------------------------------------------
- %% message "* parts_num (0)="& decimal(parts_num) &" "& decimal(parts_usr-parts_usr_start);
- %% message "* parts_int (0)="& decimal(parts_int) &" "& decimal(parts_int-parts_int_start);
- %---------------------------------------------------------------------------------------------
ef scan_bit(sw_output,Fig):
- EN_:="no_figure";
- beginfig(fig_num)
- defaultscale:=.6; draw_frame((0,0),fsize,thickness_frame) label("no figure",0.5fsize);
- endfig;
- clearit;
- %---------------------------------------------------------------------------------------------
+ EN_:="no_figure";
+ beginfig(fig_num)
+ defaultscale:=.6; draw_frame((0,0),fsize,thickness_frame) label("no figure",0.5fsize);
+ endfig;
+ clearit;
fi
%---------------------------------------------------------------------------------------------
- if scan_bit(sw_output,Mcode): proc_mc_out; fi
- if scan_bit(sw_output,Report): proc_report_out; fi
- if scan_bit(sw_output,MOL2k): proc_mol_out(2000); fi
- if scan_bit(sw_output,MOL3k): proc_mol_out(3000); fi
+ if err_cnt=0:
+ if scan_bit(sw_output,Mcode): proc_mc_out; message "["&decimal(fig_num)&"]:"&EN; fi
+ if scan_bit(sw_output,Report): proc_report_out; message "["&decimal(fig_num)&"]:"&EN; fi
+ if scan_bit(sw_output,MOL2k): proc_mol_out(2000); message "["&decimal(fig_num)&"]:"&EN; fi
+ if scan_bit(sw_output,MOL3k): proc_mol_out(3000); message "["&decimal(fig_num)&"]:"&EN; fi
+ fi
%---------------------------------------------------------------------------------------------
restore_par(parameter_list);
endgroup;
enddef;
-%==================================================================================================
+%=================================================================================================
def readm(text s)=
save fw_n,bw_n;
for list=s:
@@ -283,8 +276,7 @@ def read_unit(expr n)=
if firstc=":": nF:=1; ef firstc="=": nF:=2; ef firstc="*": nF:=3; ef firstc="+": nF:=4;
ef firstc="%":
else:
- fw_n:=scan_char(" ",temps,1,1)-1;
- temps:=substring(fw_n,length(temps)) of temps;
+ fw_n:=scan_char(" ",temps,1,1)-1; temps:=substring(fw_n,length(temps)) of temps;
if nF=1: mc_indent[incr mc_row]:=fw_n; mc[mc_row]:=temps; mc:=mc&temps;
ef nF=2: op_indent[incr op_row]:=fw_n; op[op_row]:=temps; op:=op&temps;
ef nF=3: ex_indent[incr ex_row]:=fw_n; ex[ex_row]:=temps; ex:=ex&temps;
@@ -292,7 +284,7 @@ def read_unit(expr n)=
fi
fi
endfor
- fi
+ fi
enddef;
%=================================================================================================
vardef get_adr(expr t,v)=
@@ -314,16 +306,17 @@ def putm=
if ex_row>=1: ext(scantokens(ex)) fi
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-vardef '(text t)= parts_num:=parts_num+1; read_mcf(parts_num)(t); parts_num enddef;
-vardef read_id(text t)= parts_num:=parts_num+1;
- read_mcf(parts_num)(|,#rate_cr,t,##,(_com,_rest)); parts_num enddef;
-vardef read_ud(text t)= parts_num:=parts_num+1;
- read_mcf(parts_num)(dum,dum,|,t,(_com,_rest)); parts_num enddef;
-vardef abs_adress primary n = if n LT 0:: (n+360)-4095 else:: n-4095 fi enddef;
+vardef '(text t)= pcode_num:=pcode_num+-1; read_mcf(pcode_num)(t); pcode_num enddef;
+vardef read_id(text t)= pcode_num:=pcode_num+-1;
+ read_mcf(pcode_num)(|,#rate_cr,t,##,(_com,_rest)); pcode_num enddef;
+vardef read_ud(text t)= pcode_num:=pcode_num+-1;
+ read_mcf(pcode_num)(dum,dum,|,t,(_com,_rest)); pcode_num enddef;
+vardef abs_adress primary n = if n LT 0:: (n+-360)-4095 else:: n-4095 fi enddef;
primarydef a from_until b = (_from,a),(_until,b) enddef;
+primarydef a op_plus b = read_id(a,b) enddef;
tertiarydef a bond__bond b = (a,b) enddef;
-tertiarydef a bond___bond b = (a+0.5,b) enddef;
-tertiarydef a bond____bond b = (a+0.5,b+0.5) enddef;
+tertiarydef a bond___bond b = (a+-2000,b) enddef;
+tertiarydef a bond____bond b = (a+-2000,b+-2000) enddef;
tertiarydef a op_equ b = if (known a)and(known b):: change_bond(a,b) else:: _nop fi enddef;
tertiarydef a op_col b = if (known a)and(known b):: change_atom(a,b) else:: _nop fi enddef;
tertiarydef a op_hat b = if known b:: (_tmp_rot,b),a else:: _nop,a fi enddef;
@@ -344,208 +337,232 @@ def group_wv secondary n = /n~wv enddef; def group_nb secondary n = /n~nb endde
%=================================================================================================
def read_mcf(expr n)(text t)=
begingroup
- save nCP;
if unknown inside_mc::
- save /,//,/*,*/,**,*/*,~,^,',`,<,>,:,=,\,\\,*\,\*,*\*,@,@$,$,&,&$,#,##,{,},|,||,_,CP,CA,
- --,---,----,inside_mc;
- | :=mark_adress; || :=reset_adress; ##:=reset_length; _:=Me;
+ save /,//,/*,*/,**,*/*,~,^,',`,<,>,:,=,+,\,\\,*\,\*,*\*,@,@$,$,&,&$,#,##,{,},|,||,_,
+ --,---,----,CP,CA,CC,DL,FR,inside_mc;
+ inside_mc:=1; | :=mark_adress; || :=reset_adress; ##:=reset_length; _:=Me;
\:=0; \\:=zero_dm; *\:=zero_wf; \*:=zero_zf; *\*:=zero_wv;
let = ==op_equ; let : ==op_col; let ^==op_hat; let ~==op_til; let > ==op_lth; let `==op_bqu;
let -- == bond__bond; let --- == bond___bond; let ---- == bond____bond;
- def $==abs_adress enddef; def &$==&.$ enddef; def '==read_id enddef;
- def {==read_number( enddef; def CP == com_par enddef; def CA == com_par_adr enddef;
let }==); let @$==jump_atom_abs; let < ==rot_angle; let @==jump_atom; let &==cyc_atom;
let #==chg_length; let /==group_si; let //==group_dm; let */==group_wf; let /*==group_zf;
- let */*==group_wv; let **==group_nb;
- inside_mc:=1;
+ let */*==group_wv; let **==group_nb; let CP == pcode_add; let CA == pcode_add_adr;
+ let FR == fuse_ring_bonds; def DL(expr p)==CA(_set_line,dl,p) enddef;
+ def CB(expr p)==CP(_mk_bond,p) enddef; def CC(expr p)==CP(_com,p) enddef;
+ def $==abs_adress enddef; def &$==&.$ enddef; def '==read_id enddef; let +==op_plus;
+ def {==read_number( enddef;
fi
%----------------------------------------------------------------------------------------------
- nCP:=0;
+ pcode_cnt[n]:=0;
for list==t::
if known list::
- if pair list:: parts_com[n][incr nCP]:=xpart(list); parts_par[n][nCP]:=ypart(list);
+ if pair list:: pcode_cnt[n]:= pcode_cnt[n]+-1;
+ pcode_com[n][pcode_cnt[n]]:=xpart(list);
+ pcode_par[n][pcode_cnt[n]]:=ypart(list);
ef numeric list::
if list==_nop:: message "unknown command in "AND decimal(n);
- ef list>=parts_emb_start::
- for i==1 upto parts_cnt[list]::
- parts_com[n][incr nCP]:=parts_com[list][i]; parts_par[n][nCP]:=parts_par[list][i];
- endfor
- else:: parts_com[n][incr nCP]:=_mk_bond; parts_par[n][nCP]:=list; fi
+ ef list>=pcode_emb_start:: expand_pcode(n,list);
+ else::
+ pcode_cnt[n]:=pcode_cnt[n]+-1;
+ pcode_com[n][pcode_cnt[n]]:=_mk_bond; pcode_par[n][pcode_cnt[n]]:=list;
fi
+ fi
else:: message "unknown command in "AND decimal(n);
fi
endfor
- parts_cnt[n]:=nCP;
endgroup
enddef;
%-------------------------------------------------------------------------------------------------
+def expand_pcode(expr n,a)=
+ if n==0::
+ for i==1 upto pcode_cnt[a]::
+ if pcode_com[a][i]>=pcode_emb_start:: expand_pcode(n,pcode_com[a][i]);
+ else:: pcode_cnt[n]:=pcode_cnt[n]+-1;
+ pcode_com[n][pcode_cnt[n]]:=pcode_com[a][i];
+ pcode_par[n][pcode_cnt[n]]:=pcode_par[a][i];
+ fi
+ endfor
+ else::
+ pcode_cnt[n]:=pcode_cnt[n]+-1; pcode_com[n][pcode_cnt[n]]:=a;
+ fi
+enddef;
+%-------------------------------------------------------------------------------------------------
vardef read_number(text t)=
save :,','`;
- let : == from_until; def ' == +0.5 enddef; def '` == +0.5` enddef; parts_int:=parts_int+1;
+ let : == from_until; def ' == +-2000 enddef; def '` == +-2000` enddef;
+ pcode_int:=pcode_int+-1;
nA:=0;
for list==t::
if known list::
if numeric list::
- if list==_nop:: message "unknown command in "AND decimal(parts_int);
- else:: parts_com[parts_int][incr nA]:=_numeric; parts_par[parts_int][nA]:=list;
+ if list==_nop:: message "unknown command in "AND decimal(pcode_int);
+ else:: nA:=nA+-1; pcode_com[pcode_int][nA]:=_numeric; pcode_par[pcode_int][nA]:=list;
fi
ef pair list::
if xpart(list)==_from:: nB:=ypart(list);
ef xpart(list)==_until:: nC:=ypart(list);
for i==nB upto nC::
- parts_com[parts_int][incr nA]:=_numeric; parts_par[parts_int][nA]:=i;
+ nA:=nA+-1; pcode_com[pcode_int][nA]:=_numeric; pcode_par[pcode_int][nA]:=i;
endfor
- else:: parts_com[parts_int][incr nA]:=xpart(list); parts_par[parts_int][nA]:=ypart(list);
+ else:: nA:=nA+-1;
+ pcode_com[pcode_int][nA]:=xpart(list); pcode_par[pcode_int][nA]:=ypart(list);
fi
fi
- else:: message "unknown command in "AND decimal(parts_int);
+ else:: message "unknown command in "AND decimal(pcode_int);
fi
endfor
- parts_cnt[parts_int]:=nA; parts_int
+ pcode_cnt[pcode_int]:=nA; pcode_int
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def fuse_ring(expr a,b) =
- CP(_jp_bond,a) CP(_rot_ang,180) CP(_get_len,a) CP(_com,_len_s) CP(_chg_len,_ring_len)
- for i==1 upto b-2:: CP(_mk_bond,360 DIV b) endfor
- CP(_com,_len_e) if a<=0:: CP(_cyc_eB,a-b+2) else:: CP(_cyc_eB,a) fi enddef;
+ CP(_jp_bond,a) CP(_rot_ang,180) CP(_get_len,a) CC(_len_s) CP(_chg_len,_ring_len)
+ for i==1 upto b-2:: CB(360 DIV b) endfor
+ CC(_len_e) if a<=0:: CP(_cyc_eB,a-b+-2) else:: CP(_cyc_eB,a) fi
+enddef;
%-------------------------------------------------------------------------------------------------
def fuse_ring_bonds(expr s,e,b,c) =
- CP(_jp_bond,s) CP(_rot_ang,180) CP(_com,_len_s)
- if b==6:: CP(_chg_len,1) for i==1 upto c-1:: CP(_mk_bond,60) endfor
- ef b==5:: if c==2:: CP(_chg_len,1.25) CP(_mk_bond,80)
- ef c==3:: CP(_chg_len,1.1) CP(_mk_bond,78) CP(_mk_bond,72) fi
- ef b==4:: CP(_chg_len,1.225) CP(_mk_bond,105) fi
- CP(_com,_len_e) if e<=0:: CP(_cyc_eB,e-c+1) else:: CP(_cyc_eB,e) fi
+ CP(_jp_bond,s) CP(_rot_ang,180) CC(_len_s)
+ if b==6:: CP(_chg_len,1) for i==1 upto c-1:: CB(60) endfor
+ ef b==5:: if c==2:: CP(_chg_len,1.25) CB(80) ef c==3:: CP(_chg_len,1.1) CB(78) CB(72) fi
+ ef b==4:: CP(_chg_len,1.225) CB(105)
+ fi
+ CC(_len_e) if e<=0:: CP(_cyc_eB,e-c+-1) else:: CP(_cyc_eB,e) fi
enddef;
%-------------------------------------------------------------------------------------------------
def fuse_ring_size(expr a,b,c) =
- CP(_jp_bond,a) CP(_rot_ang,180) CP(_com,_len_s) CP(_chg_len,c DIV 10)
- if b==5:: CP(_mk_bond,72-((c-9) MUL 1.5)) CP(_mk_bond,72+(c-9)) CP(_mk_bond,72+(c-9))
- ef b==6:: CP(_mk_bond,60-(c-8)) for i==1 upto 3:: CP(_mk_bond,60+((c-8) DIV 2)) endfor
- ef b==7:: CP(_mk_bond,360 DIV 7-(c-8))
- for i==1 upto 4:: CP(_mk_bond,360 DIV 7+((c-8) DIV 2.5)) endfor
- ef b==8:: CP(_mk_bond,45-(c-8)) for i==1 upto 5:: CP(_mk_bond,45+((c-8) DIV 3)) endfor fi
- CP(_com,_len_e) if a<=0:: CP(_cyc_eB,a-b+2) else:: CP(_cyc_eB,a) fi enddef;
+ CP(_jp_bond,a) CP(_rot_ang,180) CC(_len_s) CP(_chg_len,c DIV 10)
+ if b==5:: CB(72-((c-9) MUL 1.5)) CB(72+-(c-9)) CB(72+-(c-9))
+ ef b==6:: CB(60-(c-8)) for i==1 upto 3:: CB(60+-((c-8) DIV 2)) endfor
+ ef b==7:: CB(360 DIV 7-(c-8)) for i==1 upto 4:: CB(360 DIV 7+-((c-8) DIV 2.5)) endfor
+ ef b==8:: CB(45-(c-8)) for i==1 upto 5:: CB(45+-((c-8) DIV 3)) endfor
+ fi
+ CC(_len_e) if a<=0:: CP(_cyc_eB,a-b+-2) else:: CP(_cyc_eB,a) fi
+enddef;
%=================================================================================================
vardef change_bond(expr a,b) =
- if known b:: parts_int:=parts_int+1; nC:=0;
+ if known b:: pcode_int:=pcode_int+-1; nC:=0;
if numeric b::
if (b>=si)and(b<=bd_)::
- if a>=parts_int_start::
- for i==1 upto parts_cnt[a]::
- if parts_com[a][i]==_numeric::
- if frac parts_par[a][i]==0:: CA(_set_line,b,parts_par[a][i])
- ef b==dl:: CA(_set_line,dr,floor parts_par[a][i])
- ef b==dr:: CA(_set_line,dl,floor parts_par[a][i])
- else:: CA(_set_line,b,floor parts_par[a][i]) fi fi
+ if a>=pcode_int_start::
+ for i==1 upto pcode_cnt[a]::
+ if pcode_com[a][i]==_numeric::
+ if pcode_par[a][i]<=1800:: CA(_set_line,b,pcode_par[a][i])
+ ef b==dl:: CA(_set_line,dr,pcode_par[a][i]-2000)
+ ef b==dr:: CA(_set_line,dl,pcode_par[a][i]-2000)
+ else:: CA(_set_line,b,pcode_par[a][i]-2000)
+ fi
+ fi
endfor
- else:: CP(_set_adr,a) CP(_set_line,b) fi
+ else:: CP(_set_adr,a) CP(_set_line,b)
+ fi
elseif (b>=?3)and(b<=?8[15])::
if numeric a::
- if a>=parts_int_start::
- for i==1 upto parts_cnt[a]::
- if parts_com[a][i]==_numeric::
- if b==Ph1:: fuse_ring(parts_par[a][i],6) CA(_set_line,dl,-2) CA(_set_line,dl,-4)
- ef b==Ph2:: fuse_ring(parts_par[a][i],6) CA(_set_line,dl,-1) CA(_set_line,dl,-3)
- CA(_set_line,dl,-5)
- ef (b>=?5[11])and(b<=?5[15]):: fuse_ring_size(a,5,b-?5[11]+11)
- ef (b>=?6[11])and(b<=?6[15]):: fuse_ring_size(a,6,b-?6[11]+11)
- ef (b>=?7[11])and(b<=?7[15]):: fuse_ring_size(a,7,b-?7[11]+11)
- ef (b>=?8[11])and(b<=?8[15]):: fuse_ring_size(a,8,b-?8[11]+11)
- else:: fuse_ring(parts_par[a][i],b-?3+3) fi
+ if a>=pcode_int_start::
+ for i==1 upto pcode_cnt[a]::
+ if pcode_com[a][i]==_numeric::
+ if b==Ph1:: fuse_ring(pcode_par[a][i],6) DL(-2) DL(-4)
+ ef b==Ph2:: fuse_ring(pcode_par[a][i],6) DL(-1) DL(-3) DL(-5)
+ ef (b>=?5[11])and(b<=?8[15]):: fuse_ring_size(a,pcode_com[b][1],pcode_par[b][1])
+ else:: fuse_ring(pcode_par[a][i],b-?3+-3) fi
else::
if b==?6::
- if (frac parts_com[a][i]==0)and(frac parts_par[a][i]==0)::
- fuse_ring_bonds(parts_com[a][i],parts_par[a][i],6,4)
- ef frac parts_par[a][i]==0::
- fuse_ring_bonds(floor parts_com[a][i],parts_par[a][i],6,3)
- else:: fuse_ring_bonds(floor parts_com[a][i],floor parts_par[a][i],6,2) fi
+ if (pcode_com[a][i]<=1800)and(pcode_par[a][i]<=1800)::
+ FR(pcode_com[a][i],pcode_par[a][i],6,4)
+ ef pcode_par[a][i]<=1800:: FR(pcode_com[a][i]-2000,pcode_par[a][i],6,3)
+ else:: FR(pcode_com[a][i]-2000,pcode_par[a][i]-2000,6,2)
+ fi
ef b==?5::
- if (frac parts_com[a][i]==0)and(frac parts_par[a][i]==0)::
- fuse_ring_bonds(parts_com[a][i],parts_par[a][i],5,3)
- ef frac parts_par[a][i]==0::
- fuse_ring_bonds(floor parts_com[a][i],parts_par[a][i],5,2) fi
- ef b==?4:: fuse_ring_bonds(parts_com[a][i],parts_par[a][i],4,2)
- ef b==Ph1:: fuse_ring_bonds(parts_com[a][i],parts_par[a][i],6,4)
- CA(_set_line,dl,-1) CA(_set_line,dl,-3)
- ef b==Ph2:: fuse_ring_bonds((parts_com[a][i],parts_par[a][i]),6,4)
- CA(_set_line,dl,-2) CA(_set_line,dl,-4) fi fi endfor
+ if (pcode_com[a][i]<=1800)and(pcode_par[a][i]<=1800)::
+ FR(pcode_com[a][i],pcode_par[a][i],5,3)
+ ef pcode_par[a][i]<=1800:: FR(pcode_com[a][i]-2000,pcode_par[a][i],5,2)
+ fi
+ ef b==?4:: FR(pcode_com[a][i],pcode_par[a][i],4,2)
+ ef b==Ph1:: FR(pcode_com[a][i],pcode_par[a][i],6,4) DL(-1) DL(-3)
+ ef b==Ph2:: FR(pcode_com[a][i],pcode_par[a][i],6,4) DL(-2) DL(-4)
+ fi
+ fi
+ endfor
else::
- if b==Ph1:: fuse_ring(a,6) CA(_set_line,dl,-2) CA(_set_line,dl,-4)
- ef b==Ph2:: fuse_ring(a,6) CA(_set_line,dl,-1) CA(_set_line,dl,-3) CA(_set_line,dl,-5)
- ef (b>=?5[11])and(b<=?5[15]):: fuse_ring_size(a,5,b-?5[11]+11)
- ef (b>=?6[11])and(b<=?6[15]):: fuse_ring_size(a,6,b-?6[11]+11)
- ef (b>=?7[11])and(b<=?7[15]):: fuse_ring_size(a,7,b-?7[11]+11)
- ef (b>=?8[11])and(b<=?8[15]):: fuse_ring_size(a,8,b-?8[11]+11)
- else:: fuse_ring(a,b-?3+3)
+ if b==Ph1:: fuse_ring(a,6) DL(-2) DL(-4)
+ ef b==Ph2:: fuse_ring(a,6) DL(-1) DL(-3) DL(-5)
+ ef (b>=?5[11])and(b<=?8[15]):: fuse_ring_size(a,pcode_com[b][1],pcode_par[b][1])
+ else:: fuse_ring(a,b-?3+-3)
fi
fi
ef pair a::
- if b==?6::
- if (frac xpart a==0)and(frac ypart a==0):: fuse_ring_bonds(xpart a,ypart a,6,4)
- ef frac ypart a==0:: fuse_ring_bonds(floor xpart a,ypart a,6,3)
- else:: fuse_ring_bonds(floor xpart a,floor ypart a,6,2) fi
- ef b==?5::
- if (frac xpart a==0)and(frac ypart a==0):: fuse_ring_bonds(xpart a,ypart a,5,3)
- ef frac ypart a==0:: fuse_ring_bonds(floor xpart a,ypart a,5,2) fi
- ef b==?4:: fuse_ring_bonds(xpart a,ypart a,4,2)
- fi
+ if b==?6:: if (xpart a<=1800)and(ypart a<=1800):: FR(xpart a,ypart a,6,4)
+ ef ypart a<=1800:: FR((xpart a)-2000,ypart a,6,3)
+ else:: FR((xpart a)-2000,(ypart a)-2000,6,2)
+ fi
+ ef b==?5:: if (xpart a<=1800)and(ypart a<=1800):: FR(xpart a,ypart a,5,3)
+ ef ypart a<=1800:: FR((xpart a)-2000,ypart a,5,2)
+ fi
+ ef b==?4:: FR(xpart a,ypart a,4,2)
fi
fi
- elseif color b:: color_list[incr cntC]:=b; CA(_set_colorB,cntC,a) fi
- parts_cnt[parts_int]:=nC; parts_int fi
+ fi
+ elseif color b:: cntC:=cntC+-1; color_list[cntC]:=b; CA(_set_colorB,cntC,a) fi
+ pcode_cnt[pcode_int]:=nC; pcode_int
+ fi
enddef;
%-------------------------------------------------------------------------------------------------
vardef change_atom(expr a,b)=
- if known b:: parts_int:=parts_int+1; nC:=0;
+ if known b:: pcode_int:=pcode_int+-1; nC:=0;
if numeric b::
- if (b GT parts_emb_start)and(b<=parts_atom_end):: CA(_chg_atom,b,a)
- ef b==NH:: CA(_chg_atom,N,a) CP(_tmp_line,nl)
- CP(_com,_group_s) CA(_group_si,H,a) CP(_com,_group_e)
- ef b==N!:: CA(_chg_atom,N,a) CP(_com,_group_s) CA(_group_si,_,a) CP(_com,_group_e)
- ef b==N!2:: CA(_chg_atom,N,a) CP(_com,_group_s) CA(_group_si,!,a) CP(_com,_group_e)
- ef b==??:: CP(_com,_group_s) CP(_tmp_rot,35) CA(_group_si,_,a)
- CP(_tmp_rot,-35) CA(_group_si,_,a) CP(_com,_group_e)
- ef b==SOO:: CA(_chg_atom,S,a) CP(_com,_group_s) CP(_tmp_rot,35) CA(_group_dm,O,a)
- CP(_tmp_rot,-35) CA(_group_dm,O,a) CP(_com,_group_e)
- ef b==SO:: CA(_chg_atom,S,a) CP(_com,_group_s) CA(_group_dm,O,a) CP(_com,_group_e)
- ef b==n_:: CP(_com,_group_s) CP(_set_add,a_minus) CP(_chg_add,a) CP(_com,_group_e)
- ef b==p_:: CP(_com,_group_s) CP(_set_add,a_plus) CP(_chg_add,a) CP(_com,_group_e) fi
+ if (b GT pcode_emb_start)and(b<=pcode_atom_end):: CA(_chg_atom,b,a)
+ ef b==NH:: CA(_chg_atom,N,a) if sw_expand==0:: CP(_tmp_line,nl) fi
+ CC(_group_s) CA(_group_si,H,a) CC(_group_e)
+ ef b==N?:: CA(_chg_atom,N,a) CC(_group_s) CA(_group_si,_,a) CC(_group_e)
+ ef b==N?2:: CA(_chg_atom,N,a) CC(_group_s) CA(_group_si,!,a) CC(_group_e)
+ ef b==??:: CP(_tmp_rot, 35) CC(_group_s) CA(_group_si,_,a) CC(_group_e)
+ CP(_tmp_rot,-35) CC(_group_s) CA(_group_si,_,a) CC(_group_e)
+ ef b==n_:: CC(_group_s) CP(_set_add,MIS) CP(_chg_add,a) CC(_group_e)
+ ef b==p_:: CC(_group_s) CP(_set_add,PLS) CP(_chg_add,a) CC(_group_e)
+ fi
ef pair b::
- CP(_com,_group_s)
- if a>=parts_emb_start::
- for i==1 upto parts_cnt[a]::
- if parts_com[a][i]==_numeric::
- if frac parts_par[a][i]==0:: CA(xpart(b),ypart(b),parts_par[a][i])
- ef xpart(b)==_group_wf:: CA(_group_zf,ypart(b),floor parts_par[a][i])
- ef xpart(b)==_group_zf:: CA(_group_wf,ypart(b),floor parts_par[a][i])
- else:: CA(xpart(b),ypart(b),parts_par[a][i]) fi
- else:: CP(parts_com[a][i],parts_par[a][i]) fi
+ CC(_group_s)
+ if a>=pcode_emb_start::
+ for i==1 upto pcode_cnt[a]::
+ if pcode_com[a][i]==_numeric::
+ if pcode_par[a][i]<=1800:: CA(xpart(b),ypart(b),pcode_par[a][i])
+ ef xpart(b)==_group_wf:: CA(_group_zf,ypart(b),pcode_par[a][i]-2000)
+ ef xpart(b)==_group_zf:: CA(_group_wf,ypart(b),pcode_par[a][i]-2000)
+ else:: CA(xpart(b),ypart(b),pcode_par[a][i])
+ fi
+ else:: CP(pcode_com[a][i],pcode_par[a][i])
+ fi
endfor
else:: CA(xpart(b),ypart(b),a) fi
- CP(_com,_group_e)
- ef color b:: color_list[incr cntC]:=b; CA(_set_colorA,cntC,a) fi
- parts_cnt[parts_int]:=nC; parts_int fi
+ CC(_group_e)
+ ef color b:: cntC:=cntC+-1; color_list[cntC]:=b; CA(_set_colorA,cntC,a)
+ fi
+ pcode_cnt[pcode_int]:=nC; pcode_int
+ fi
enddef;
%-------------------------------------------------------------------------------------------------
-def com_par(expr c,p)= parts_com[parts_int][incr nC]:=c; parts_par[parts_int][nC]:=p; enddef;
-def com_par_adr(expr c,p,a)=
- if a>=parts_emb_start::
- for i==1 upto parts_cnt[a]::
- if parts_com[a][i]==_numeric:: com_par(_set_adr,parts_par[a][i]) com_par(c,p)
- else:: com_par(parts_com[a][i],parts_par[a][i]) fi endfor
- else:: com_par(_set_adr,a) com_par(c,p) fi enddef;
+def pcode_add(expr c,p)=
+ nC:=nC+-1; pcode_com[pcode_int][nC]:=c; pcode_par[pcode_int][nC]:=p; enddef;
+def pcode_add_adr(expr c,p,a)=
+ if a>=pcode_emb_start::
+ for i==1 upto pcode_cnt[a]::
+ if pcode_com[a][i]==_numeric:: pcode_add(_set_adr,pcode_par[a][i]) pcode_add(c,p)
+ else:: pcode_add(pcode_com[a][i],pcode_par[a][i])
+ fi
+ endfor
+ else:: pcode_add(_set_adr,a) pcode_add(c,p)
+ fi
+enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def ext_setup=
pickup pencircle scaled ext_defaultline;
dotlabeldiam:=3; labeloffset:=3; em:=defaultscale*defaultsize; defaultfont:=mpfont;
- let ** = scaled; let << = rotated; let => = shifted; __ = (1,0); An:=cntA; Bn:=cntB;
+ let # = scaled; let << = rotated; let => = shifted; __ = (1,0); An:=cntA; Bn:=cntB;
primarydef a /* b = point b of a enddef;
enddef;
%-------------------------------------------------------------------------------------------------
def add_to_molecule(text t)=
begingroup
- save w,h,n,l,p,am,aw,A,B,plus,minus,lonepair,__,**,=>,<<,/*;
+ save w,h,n,l,p,am,aw,A,B,An,Bn,plus,minus,lonepair,__,#,=>,<<,/*;
numeric A[]dir,B[]up,A[]ang,B[]ang;
pair __,p[],A[],B[]s,B[]e,B[]m,A[]up,A[]left,A[]right,A[]down,B[]up,B[]left,B[]right,B[]down;
path B[];
@@ -556,18 +573,20 @@ def add_to_molecule(text t)=
lonepairdiam:=0.3aw; lonepairspace:=.7aw; circlediam:=.6aw; circlepen:=.2;
for i=1 upto cntA:
A[i]:=posA[i]; A[i]ang:=angX[i]; A[i]up:=dir(angX[i]);
- A[i]left:=dir(angX[i]+90); A[i]right:=dir(angX[i]-90); A[i]down:=dir(angX[i]+180); endfor
+ A[i]left:=dir(angX[i]+90); A[i]right:=dir(angX[i]-90); A[i]down:=dir(angX[i]+180);
+ endfor
for i=1 upto cntB:
B[i]s:=posA[sB[i]]; B[i]e:=posA[eB[i]]; B[i]m:=0.5[B[i]s,B[i]e]; B[i]:=B[i]s--B[i]e;
B[i]ang:=angB[i]; B[i]up:=dir(angB[i]);
- B[i]down:=dir(angB[i]+180); B[i]left:=dir(angB[i]+90); B[i]right:=dir(angB[i]-90); endfor
+ B[i]down:=dir(angB[i]+180); B[i]left:=dir(angB[i]+90); B[i]right:=dir(angB[i]-90);
+ endfor
t addto mol_pic[cntM] also currentpicture; clearit;
endgroup;
enddef;
%-------------------------------------------------------------------------------------------------
def ext_to_fig(text t)=
begingroup
- save w,h,An,Bn,wd,ht,n,p,am,aw,__,**,<<,=>,/*;
+ save w,h,An,Bn,wd,ht,n,p,am,aw,__,#,<<,=>,/*;
pair __,p[];
ext_setup;
w:=xpart(fsize); h:=ypart(fsize);
@@ -579,10 +598,12 @@ enddef;
%-------------------------------------------------------------------------------------------------
vardef circled_plus_add= nA:=circlediam; nB:=circlepen;
image(draw fullcircle scaled nA wpcs nB;
- draw (-.5nA,0)--(.5nA,0) wpcs nB; draw (0,-.5nA)--(0,.5nA) wpcs nB;) enddef;
+ draw (-.5nA,0)--(.5nA,0) wpcs nB; draw (0,-.5nA)--(0,.5nA) wpcs nB;)
+enddef;
%-------------------------------------------------------------------------------------------------
vardef circled_minus_add= nA:=circlediam; nB:=circlepen;
- image(draw fullcircle scaled nA wpcs nB; draw (-.5nA,0)--(.5nA,0) wpcs nB;) enddef;
+ image(draw fullcircle scaled nA wpcs nB; draw (-.5nA,0)--(.5nA,0) wpcs nB;)
+enddef;
%-------------------------------------------------------------------------------------------------
vardef lone_pair_add expr n=
image(draw (0,0) wpcs lonepairdiam; draw ((0,lonepairspace) rotated n) wpcs lonepairdiam;)
@@ -592,24 +613,21 @@ def drawm(text t)=
begingroup
save f_bra,temp_strA,temp_lenE,temp_lenF,temp_cntB,f_term,f_at,f_lineT,f_rotT,angL,lenL,cpos,
tpos,f_lenT,f_envT,factor,m_wd,m_ht,raise_pos,slen,sdir,char_wd,char_ht,tcol,f_col,knownA,
- markA,markB,saveA,saveB,bondL,lenT,lineT,angT,rotT,envT,envB,rate_cr,posBs,posBe,
- group_par,group_cnt,group_com,colorA,colorB,aW,aH,fW,fH,hW,hW,hH,qH,fP,hP,
- ww,aw,ap,am,Ls,Le,pA,zA,zL,cC,cH,cO,cN,cS,cF,cP;
+ group_num,markA,markB,saveA,saveB,bondL,lenT,lineT,angT,rotT,envT,envB,rate_cr,posBs,posBe,
+ group_par,group_cnt,group_com,colorA,colorB,aW,aH,fW,fH,hW,hW,hH,qH,fP,hP,ww,aw,ap,am,
+ Ls,Le,pA,zA,zL;
numeric group_com[][],group_par[][],group_cnt[],colorA[],colorB[];
- string cC,cH,cO,cN,cS,cF,cP;
pair cpos,tpos,raise_pos,posBs,posBe,pA,Ls,Le;
path frameA[],zA,zL;
%-----------------------------------------------------------------------------------------------
- if (sw_expand=1)or(scan_bit(sw_output,MOL2k))or(scan_bit(sw_output,MOL3k)):
- expand_set; rate_cr:=1; else: rate_cr:=-ratio_chain_ring; fi
- cC:="C"; cH:="H"; cO:="O"; cN:="N"; cS:="S"; cF:="F"; cP:="P";
- cntA:=cntB:=cntC:=group_cnt:=0; str_tbl[0]:=cC; str_cnt:=2000;
+ if sw_expand=1: rate_cr:=1; else: rate_cr:=-ratio_chain_ring; fi
+ cntA:=cntB:=cntC:=group_num:=0; str_tbl[0]:="C"; str_cnt:=2000;
%-----------------------------------------------------------------------------------------------
fig_wd:=xpart(fsize); fig_ht:=ypart(fsize);
%===============================================================================================
read_mcf(0)(t,(_com,_term));
proc_bond_atom(0)(1);
- if (group_cnt>0)and(not scan_bit(sw_abbreviate,Group)): read_group(0)(1); fi
+ if (group_num>0)and(not scan_bit(sw_abbreviate,Group)): expand_group(1); fi
%-scaling---------------------------------------------------------------------------------------
if blength>1: blen:=blength; proc_size_setup; proc_skeleton(0); proc_scaling;
elseif blength>0: blen:=fig_wd*blength; proc_size_setup; proc_skeleton(0); proc_scaling;
@@ -635,7 +653,9 @@ def drawm(text t)=
if addA[i]<>0:
tempc:=char(addA[i]);
if tempc="+": chargeA[i]:=1; ef tempc="-": chargeA[i]:=-1; else: chargeA[i]:=0; fi
- else: chargeA[i]:=0; fi endfor
+ else: chargeA[i]:=0;
+ fi
+ endfor
%===============================================================================================
if scan_bit(sw_output,Fig):
%-draw atom-----------------------------------------------------------------------------------
@@ -671,7 +691,7 @@ def drawm(text t)=
erase fill unitsquare xscaled nW yscaled nH shifted (tpos-(nW/2,nH/2));
draw unitsquare xscaled nW yscaled nH shifted (tpos-(nW/2,nH/2)) wpcs 0.1;
label(decimal(i),tpos);
- fi
+ fi
endfor
fi
%---------------------------------------------------------------------------------------------
@@ -679,8 +699,7 @@ def drawm(text t)=
else: nX:=xpart(fmargin)-minX+(fig_wd-mol_wd-2xpart(fmargin))*xpart(mposition); fi
if ypart(mposition)>1: nY:=ypart(mposition)-minY;
else: nY:=ypart(fmargin)-minY+(fig_ht-mol_ht-2ypart(fmargin))*ypart(mposition); fi
- posM[0][incr cntM]:=(nX,nY);
- posM[1][cntM]:=(minX+nX,minY+nY); posM[2][cntM]:=(maxX+nX,maxY+nY);
+ posM[0][incr cntM]:=(nX,nY); posM1[cntM]:=(minX+nX,minY+nY); posM2[cntM]:=(maxX+nX,maxY+nY);
wdM[cntM]:=mol_wd; htM[cntM]:=mol_ht;
mol_pic[cntM]:=currentpicture;
clearit;
@@ -689,44 +708,22 @@ def drawm(text t)=
endgroup;
enddef;
%-------------------------------------------------------------------------------------------------
-def add_group=
- if f_at=1: nE:=getA(adrT); check_adrA(nE); else: nE:=cntA+1; fi
- group_cnt[incr group_cnt]:=0; store_group(_jp_absA,nE) store_group(_com,_len_s)
- if lineT<>nb: store_group(_tmp_line,lineT) fi
- if rotT<>0: store_group(_rot_ang,rotT) fi
- if lenT<>rate_cr: store_group(_chg_len,lenT)
- ef bondL<>rate_cr:
- if bondL>=0: store_group(_chg_len,-bondL) else: store_group(_chg_len,bondL) fi
- fi
- if envT<>hz: store_group(_chg_env,envT) fi
- if lineT=nl: store_group(_chg_len,_size_atom) store_group(_adj_ang,0) fi
- if lineT<>nb: store_group(_mk_bond,0) fi
- for i=1 upto parts_cnt[nP]: store_group(parts_com[nP][i],parts_par[nP][i]) endfor
- store_group(_com,_len_e) store_group(_chg_env,hz) store_group(_com,_term)
- if f_lineT=0: lineT:=si; fi
- if f_lenT=0: lenT:=rate_cr; fi
- if f_rotT=0: rotT:=0; fi
- if f_envT=0: envT:=hz; fi
-enddef;
-%-------------------------------------------------------------------------------------------------
-def store_group(expr a,b)=
- group_com[group_cnt][incr group_cnt[group_cnt]]:=a;
- group_par[group_cnt][group_cnt[group_cnt]]:=b; enddef;
-%=================================================================================================
-def read_group(expr a)(expr n)=
- save_group_cnt:=group_cnt; save_cntD:=parts_cnt[a];
- for i=n upto group_cnt:
+def expand_group(expr n)=
+ save_group_num:=group_num; save_pcode_cnt:=pcode_cnt[0];
+ for i=n upto group_num:
for j=1 upto group_cnt[i]:
- parts_com[a][incr parts_cnt[a]]:=group_com[i][j];
- parts_par[a][parts_cnt[a]]:=group_par[i][j];
+ if group_com[i][j]>=pcode_emb_start: expand_pcode(0,group_com[i][j]);
+ else: pcode_com[0][incr pcode_cnt[0]]:=group_com[i][j];
+ pcode_par[0][pcode_cnt[0]]:=group_par[i][j];
+ fi
endfor
endfor
- proc_bond_atom(a)(save_cntD+1);
- if group_cnt>save_group_cnt: read_group(a)(save_group_cnt+1); fi enddef;
+ proc_bond_atom(0)(save_pcode_cnt+1);
+ if group_num>save_group_num: expand_group(save_group_num+1); fi
+enddef;
%=================================================================================================
def draw_frame(expr o,p,n)=
- draw ((0,0)--(xpart p,0)--p--(0,ypart p)--cycle) shifted o withpen pensquare scaled n;
-enddef;
+ draw ((0,0)--(xpart p,0)--p--(0,ypart p)--cycle) shifted o withpen pensquare scaled n; enddef;
%-------------------------------------------------------------------------------------------------
def draw_corner(expr p,n)=
draw (0,0) wpcs n; draw(xpart p,0) wpcs n; draw p wpcs n; draw(0,ypart p) wpcs n; enddef;
@@ -747,9 +744,9 @@ def proc_scaling=
nU:=nD:=nP:=nL:=nR:=0;
for j=1 upto length(str_tbl[strA[i]]):
tempc:=subc(j,str_tbl[strA[i]]);
- if tempc="^": nU:=.5atom_wd;
- ef tempc="_": nD:=.5atom_wd;
- ef (tempc<>"{")and(tempc<>"}"): nP:=nP+atom_wd*tbl_char_wd[ASCII(tempc)]; fi
+ if tempc="^": nU:=.5atom_wd; ef tempc="_": nD:=.5atom_wd;
+ ef (tempc<>"{")and(tempc<>"}"): nP:=nP+atom_wd*tbl_char_wd[ASCII(tempc)];
+ fi
endfor
if (angX[i]<=90)or(angX[i]>=270): nR:=nP; else: nL:=nP; fi
if (nX-nL+.5atom_wd)<minX: minX:=nX-nL+.5atom_wd; fi
@@ -768,59 +765,84 @@ def proc_bond_atom(expr a)(expr n)=
bondL:=rate_cr; lenT:=rate_cr; sB[0]:=0; eB[0]:=1; lineT:=si;
addAT:=markA:=markB:=saveA:=saveB:=0;
%-----------------------------------------------------------------------------------------------
- for i=n upto parts_cnt[a]: nC:=parts_com[a][i]; nP:=parts_par[a][i];
- if nC=_mk_bond: if (nP=0)and(rotT<>0): rotT:=0; fi add_atom(0);
- ef nC=_set_adr: adrT:=nP;
- ef nC=_com: if nP=_mark: saveA:=markA; saveB:=markB; markA:=cntA; markB:=cntB;
- ef nP=_rest: markA:=saveA; markB:=saveB;
- ef nP=_moff: markA:=markB:=0;
- ef nP=_term: termA;
- ef nP=_len_s: temp_lenE:=bondL; ef nP=_len_e: bondL:=temp_lenE;
- ef nP=_len_ss: temp_lenF:=bondL; ef nP=_len_ee: bondL:=temp_lenF;
- ef nP=_group_s: f_at:=1; if lineT<>si: f_lineT:=1; fi if rotT<>0: f_rotT:=1; fi
- if lenT<>rate_cr: f_lenT:=1; fi if envT<>hz: f_envT:=1; fi
- ef nP=_group_e: f_at:=0; f_lineT:=f_rotT:=f_lenT:=f_envT:=rotT:=envT:=0;
- lineT:=si; lenT:=rate_cr; fi
- ef nC=_set_atom: temp_strA:=nP;
- ef nC=_group_si: add_group;
- ef nC=_group_dm: lineT:=dm; add_group;
- ef nC=_group_wf: lineT:=wf; add_group;
- ef nC=_group_zf: lineT:=zf; add_group;
- ef nC=_jp_bond: termA; nA:=getB(nP); check_adrB(nA); sB[cntB+1]:=sB[nA]; f_bra:=1;
- ef nC=_jp_atom: termA; nA:=getA(nP); check_adrA(nA); sB[cntB+1]:=nA; f_bra:=1;
- ef nC=_jp_absA: sB[cntB+1]:=nP; f_bra:=1; temp_cntB:=cntB;
- ef nC=_chg_atom: strA[getA(adrT)]:=parts_par[nP][1];
- ef nC=_chg_len: if nP=_ring_len: bondL:=ringL; else: bondL:=nP; fi
- ef nC=_get_len: if nP=_tmp_len: if bondL=rate_cr: bondL:=lenT; fi
- ef nP=_ring_len:
- if lenT<>rate_cr: bondL:=lenT; else: if bondL<0: bondL:=1; fi fi
- else: ringL:=lenB[getB(nP)]; fi
- ef nC=_tmp_len: lenT:=nP;
- ef nC=_set_line: lineB[getB(adrT)]:=nP;
- ef nC=_tmp_line: lineT:=nP;
- ef nC=_tmp_rot: rotT:=nP;
- ef nC=_cyc: check_adrA(getA(nP)); add_atom(getA(nP));
- ef nC=_cyc_eB: add_atom(eB[getB(nP)]);
- ef nC=_cyc_sB: add_atom(sB[getB(nP)]);
- ef nC=_chg_env: envB:=nP;
- ef nC=_tmp_env: envT:=nP;
- ef nC=_set_colorA: colorA[getA(adrT)]:=nP;
- ef nC=_set_colorB: colorB[getB(adrT)]:=nP;
- ef nC=_set_add: addAT:=nP;
- ef nC=_chg_add: addA[getA(nP)]:=addAT; addAT:=0; if rotT<>0: add_rot[getA(nP)]:=rotT; fi
- else:
- fi
+ for i=n upto pcode_cnt[a]: nC:=pcode_com[a][i]; nP:=pcode_par[a][i];
+ if nC=_mk_bond: if (nP=0)and(rotT<>0): rotT:=0; fi add_atom(0);
+ ef nC=_set_adr: adrT:=nP;
+ ef nC=_com: if nP=_mark: saveA:=markA; saveB:=markB; markA:=cntA; markB:=cntB;
+ ef nP=_rest: markA:=saveA; markB:=saveB;
+ ef nP=_moff: markA:=markB:=0;
+ ef nP=_term: termA;
+ ef nP=_len_s: temp_lenE:=bondL; ef nP=_len_e: bondL:=temp_lenE;
+ ef nP=_len_ss: temp_lenF:=bondL; ef nP=_len_ee: bondL:=temp_lenF;
+ ef nP=_group_s: f_at:=1; if lineT<>si: f_lineT:=1; fi if rotT<>0: f_rotT:=1; fi
+ if lenT<>rate_cr: f_lenT:=1; fi if envT<>hz: f_envT:=1; fi
+ ef nP=_group_e: f_at:=0; f_lineT:=f_rotT:=f_lenT:=f_envT:=rotT:=envT:=0;
+ lineT:=si; lenT:=rate_cr; fi
+ ef nC=_set_atom: temp_strA:=nP;
+ ef nC=_group_si: add_group;
+ ef nC=_group_dm: lineT:=dm; add_group;
+ ef nC=_group_wf: lineT:=wf; add_group;
+ ef nC=_group_zf: lineT:=zf; add_group;
+ ef nC=_jp_bond: termA; nA:=getB(nP); check_adrB(nA); sB[cntB+1]:=sB[nA]; f_bra:=1;
+ ef nC=_jp_atom: termA; nA:=getA(nP); check_adrA(nA); sB[cntB+1]:=nA; f_bra:=1;
+ ef nC=_jp_absA: sB[cntB+1]:=nP; f_bra:=1; temp_cntB:=cntB;
+ ef nC=_chg_atom: strA[getA(adrT)]:=pcode_par[nP][1];
+ ef nC=_chg_len: if nP=_ring_len: bondL:=ringL; else: bondL:=nP; fi
+ ef nC=_get_len: if nP=_tmp_len: if bondL=rate_cr: bondL:=lenT; fi
+ ef nP=_ring_len:
+ if lenT<>rate_cr: bondL:=lenT; else: if bondL<0: bondL:=1; fi fi
+ else: ringL:=lenB[getB(nP)]; fi
+ ef nC=_tmp_len: lenT:=nP;
+ ef nC=_set_line: lineB[getB(adrT)]:=nP;
+ ef nC=_tmp_line: lineT:=nP;
+ ef nC=_tmp_rot: rotT:=nP;
+ ef nC=_cyc: check_adrA(getA(nP)); add_atom(getA(nP));
+ ef nC=_cyc_eB: add_atom(eB[getB(nP)]);
+ ef nC=_cyc_sB: add_atom(sB[getB(nP)]);
+ ef nC=_chg_env: envB:=nP;
+ ef nC=_tmp_env: envT:=nP;
+ ef nC=_set_colorA: colorA[getA(adrT)]:=nP;
+ ef nC=_set_colorB: colorB[getB(adrT)]:=nP;
+ ef nC=_set_add: addAT:=nP;
+ ef nC=_chg_add: addA[getA(nP)]:=addAT; addAT:=0; if rotT<>0: add_rot[getA(nP)]:=rotT; fi
+ else:
+ fi
endfor
enddef;
%-------------------------------------------------------------------------------------------------
+def add_group=
+ if f_at=1: nE:=getA(adrT); check_adrA(nE); else: nE:=cntA+1; fi
+ group_cnt[incr group_num]:=0; store_group(_jp_absA,nE) store_group(_com,_len_s)
+ if lineT<>nb: store_group(_tmp_line,lineT) fi
+ if rotT<>0: store_group(_rot_ang,rotT) fi
+ if lenT<>rate_cr: store_group(_chg_len,lenT)
+ ef bondL<>rate_cr:
+ if bondL>=0: store_group(_chg_len,-bondL) else: store_group(_chg_len,bondL) fi fi
+ if envT<>hz: store_group(_chg_env,envT) fi
+ if lineT=nl: store_group(_chg_len,_size_atom) store_group(_adj_ang,0) fi
+ if lineT<>nb: store_group(_mk_bond,0) fi
+ for i=1 upto pcode_cnt[nP]: store_group(pcode_com[nP][i],pcode_par[nP][i]) endfor
+ store_group(_com,_len_e) store_group(_chg_env,hz) store_group(_com,_term)
+ if f_lineT=0: lineT:=si; fi
+ if f_lenT=0: lenT:=rate_cr; fi
+ if f_rotT=0: rotT:=0; fi
+ if f_envT=0: envT:=hz; fi
+enddef;
+%-------------------------------------------------------------------------------------------------
+def store_group(expr a,b)=
+ group_com[group_num][incr group_cnt[group_num]]:=a;
+ group_par[group_num][group_cnt[group_num]]:=b;
+enddef;
+%-------------------------------------------------------------------------------------------------
def add_atom(expr n)=
lineB[incr cntB]:=lineT; lineT:=si;
if lenT=rate_cr: lenB[cntB]:=bondL; else: lenB[cntB]:=lenT; lenT:=rate_cr; fi
- if f_bra=0: sB[cntB]:=incr cntA; strA[cntA]:=temp_strA;
+ if f_bra=0: strA[incr cntA]:=temp_strA; sB[cntB]:=cntA;
addA[cntA]:=addAT; addAT:=temp_strA:=add_rot[cntA]:=0;
if rotT<>0: add_rot[cntA]:=rotT; rotT:=0; fi
else: f_bra:=0; fi
- if n=0: eB[cntB]:=cntA+1; f_term:=0; else: eB[cntB]:=n; f_term:=1; fi enddef;
+ if n=0: eB[cntB]:=cntA+1; f_term:=0; else: eB[cntB]:=n; f_term:=1; fi
+enddef;
%-------------------------------------------------------------------------------------------------
def check_adrA(expr n)=
if (n>iif(f_term=0,cntA+1,cntA))or(n<=0): errmessage("cntA=[ "&decimal(n)&" ]"); fi enddef;
@@ -831,28 +853,26 @@ def proc_skeleton(expr n)=
envT:=envB:=f_lineT:=f_rotT:=f_lenT:=f_envT:=0; lineT:=si; angT:=mangle;
angA[0]:=angB[0]:=angX[0]:=0; posA[0]:=posBs:=posBe:=(0,0);
%-----------------------------------------------------------------------------------------------
- for i=1 upto parts_cnt[n]: nC:=parts_com[n][i]; nP:=parts_par[n][i];
- if nC=_mk_bond: if (nP=0)and(rotT<>0):nP:=rotT; rotT:=0; fi add_bond(nP,1);
- ef nC=_com: if nP=_mark: saveA:=markA; saveB:=markB; markA:=cntA; markB:=cntB;
- ef nP=_rest: markA:=saveA; markB:=saveB;
- ef nP=_moff: markA:=markB:=0; ef nP=_term: termB;
- ef nP=_group_e: lineT:=si; lenT:=rate_cr; rotT:=envT:=0; fi
- ef nC=_jp_bond: termB; nA:=getB(nP); posBs:=posA[sB[nA]]; angT:=angB[nA]; f_bra:=1; rotT:=0;
- ef nC=_jp_atom: termB; adrT:=getA(nP); posBs:=posA[adrT]; angT:=angX[adrT]; f_bra:=1; rotT:=0;
- ef nC=_jp_absA: adrT:=nP; posBs:=posA[adrT]; angT:=angX[adrT];
- f_bra:=1; rotT:=0; temp_cntB:=cntB;
- ef nC=_adj_ang: angT:=adjust_ang(angT);
- ef nC=_rot_ang: if nP>-3700: angT:=(angT+nP) mod 360; else: angT:=(nP+4095) mod 360; fi
- ef nC=_tmp_rot: rotT:=nP;
- ef nC=_group_si: rotT:=0;
- ef nC=_group_wf: rotT:=0;
- ef nC=_chg_env: envB:=nP;
- ef nC=_tmp_env: envT:=nP;
- ef nC=_cyc: add_bond(angle(posA[getA(nP)]-posBs)-angT,0);
- ef nC=_cyc_sB: add_bond(angle(posA[sB[getB(nP)]]-posBs)-angT,0);
- ef nC=_cyc_eB: add_bond(angle(posA[eB[getB(nP)]]-posBs)-angT,0);
- else:
- fi
+ for i=1 upto pcode_cnt[n]: nC:=pcode_com[n][i]; nP:=pcode_par[n][i];
+ if nC=_mk_bond: if (nP=0)and(rotT<>0):nP:=rotT; rotT:=0; fi add_bond(nP,1);
+ ef nC=_com: if nP=_mark: saveA:=markA; saveB:=markB; markA:=cntA; markB:=cntB;
+ ef nP=_rest: markA:=saveA; markB:=saveB;
+ ef nP=_moff: markA:=markB:=0; ef nP=_term: termB;
+ ef nP=_group_e: lineT:=si; lenT:=rate_cr; rotT:=envT:=0; fi
+ ef nC=_jp_bond: termB; nA:=getB(nP); posBs:=posA[sB[nA]]; angT:=angB[nA]; f_bra:=1; rotT:=0;
+ ef nC=_jp_atom: termB; adrT:=getA(nP); posBs:=posA[adrT]; angT:=angX[adrT]; f_bra:=1; rotT:=0;
+ ef nC=_jp_absA: adrT:=nP; posBs:=posA[adrT]; angT:=angX[adrT];
+ f_bra:=1; rotT:=0; temp_cntB:=cntB;
+ ef nC=_adj_ang: angT:=adjust_ang(angT);
+ ef nC=_rot_ang: if nP>-3700: angT:=(angT+nP) mod 360; else: angT:=(nP+4095) mod 360; fi
+ ef nC=_tmp_rot: rotT:=nP;
+ ef nC=_chg_env: envB:=nP;
+ ef nC=_tmp_env: envT:=nP;
+ ef nC=_cyc: add_bond(angle(posA[getA(nP)]-posBs)-angT,0);
+ ef nC=_cyc_sB: add_bond(angle(posA[sB[getB(nP)]]-posBs)-angT,0);
+ ef nC=_cyc_eB: add_bond(angle(posA[eB[getB(nP)]]-posBs)-angT,0);
+ else:
+ fi
endfor
enddef;
%-------------------------------------------------------------------------------------------------
@@ -876,10 +896,13 @@ enddef;
%-------------------------------------------------------------------------------------------------
vardef arrange_ang(expr n)=
if cntB=0: angT:=(angT-180) mod 360; 180
- else: if envB>=parts_emb_start: parts_par[envB][cntB-temp_cntB+3]
+ else: if envB>=pcode_emb_start: pcode_par[envB][cntB-temp_cntB+3]
else: if envB=hz: if n=0: 60 ef n<=90: -60 ef n<=180: 60 ef n<270: -60 else: 60 fi
ef envB=vt: if n=0: -60 ef n<90: 60 ef n<=180: -60 ef n<=270: 60 else: -60 fi
- ef abs(envB)<=180: envB fi fi fi
+ ef abs(envB)<=180: envB
+ fi
+ fi
+ fi
enddef;
%-------------------------------------------------------------------------------------------------
vardef adjust_ang(expr n)= if (n<40)or(n>320): 0 ef n<140: 90 ef n<220: 180 else: 270 fi enddef;
@@ -891,14 +914,16 @@ def termA=
if f_term=0:
if f_bra=0: strA[incr cntA]:=temp_strA; addA[cntA]:=addAT; add_rot[cntA]:=rotT;
addAT:=temp_strA:=rotT:=0;
- else: f_bra:=0; fi
- f_term:=1; fi
+ else: f_bra:=0;
+ fi
+ f_term:=1;
+ fi
enddef;
%-------------------------------------------------------------------------------------------------
def termB= if f_term=0: if f_bra=0: angX[incr cntA]:=angT; else:f_bra:=0; fi f_term:=1; fi enddef;
%-------------------------------------------------------------------------------------------------
vardef glu_atom(expr n)=
- if strA[n]<>0: nE:=angT mod 90; nF:=0.5atom_wd; (iif(nE<45,sind nE,cosd nE)*nF)++nF else: 0 fi
+ if strA[n]<>0: nE:=angT mod 90; nF:=0.5atom_wd; (iif(nE<45,sind nE,cosd nE)*nF)+++nF else: 0 fi
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def draw_atom(expr n)=
@@ -908,7 +933,8 @@ def draw_atom(expr n)=
for i=1 upto slen:
if nC=0: tempc:=subc(i,temps);
if (sdir=-1)and(tempc="{"):
- nD:=i; nC:=0; for j=nD upto slen: nC:=nC+1; exitif subc(j+1,temps)="}"; endfor fi
+ nD:=i; nC:=0; for j=nD upto slen: nC:=nC+1; exitif subc(j+1,temps)="}"; endfor
+ fi
else: nC:=nC-1; tempc:=subc(nD+nC,temps); fi
if tempc="_": raise_pos:=iif(raise_pos=(0,0),(0,-.5atom_wd),(0,0));
ef tempc="^": raise_pos:=iif(raise_pos=(0,0),(0, .5atom_wd),(0,0));
@@ -920,11 +946,13 @@ def draw_atom(expr n)=
if known tcol: if tcol<>0: drawoptions(withcolor color_list[tcol]); f_col:=1; fi fi
if atomfont="draw": draw_char(tempc,tpos+raise_pos); else: label(tempc,tpos+raise_pos); fi
if f_col=1: drawoptions(); fi
- tpos:=tpos+(.5char_wd*sdir,0); fi
+ tpos:=tpos+(.5char_wd*sdir,0);
+ fi
endfor
nA:=0.56atom_wd; nB:=0.06atom_wd;
if sdir=1: frameA[n]:=posA[n]-(nA,nA)--tpos+(nB,-nA)--tpos+(nB,nA)--posA[n]+(-nA,nA)--cycle;
- else: frameA[n]:=tpos-(nB,nA)--posA[n]+(nA,-nA)--posA[n]+(nA,nA)--tpos+(-nB,nA)--cycle; fi
+ else: frameA[n]:=tpos-(nB,nA)--posA[n]+(nA,-nA)--posA[n]+(nA,nA)--tpos+(-nB,nA)--cycle;
+ fi
if scan_bit(sw_frame,Atom): draw frameA[n] wpcs thickness_frame; fi
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1003,11 +1031,15 @@ enddef;
%------------------------------------------------------------------------------------------------
def wz_put(expr a,b,c)= nB:=round(lenL/hash_gap);
for i=1 upto nB: nA:=i/nB; if i=1: nD:=0; else: nD:=(i-ratio_hash_black)/nB; fi
- fill nD[a,b]--nD[a,c]--nA[a,c]--nA[a,b]--cycle; endfor enddef;
+ fill nD[a,b]--nD[a,c]--nA[a,c]--nA[a,b]--cycle;
+ endfor
+enddef;
%------------------------------------------------------------------------------------------------
def bz_put(expr a,b,c,d)= nB:=round(lenL/hash_gap);
for i=0 upto nB-1: nA:=i/nB; nD:=nA+ratio_hash_black/nB;
- fill nA[b,a]--nA[d,c]--nD[d,c]--nD[b,a]--cycle; endfor enddef;
+ fill nA[b,a]--nA[d,c]--nD[d,c]--nD[b,a]--cycle;
+ endfor
+enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def char_size_set(expr w,h)(expr s)=
for j=1 upto length(s): nN:=ASCII(subc(j,s)); tbl_char_wd[nN]:=w; tbl_char_ht[nN]:=h; endfor
@@ -1053,13 +1085,13 @@ def draw_char(expr s,p)=
hP:=fP/2; qP:=fP/4; fW:=aW-hP; hW:=aW/2; fH:=aH-hP; hH:=aH/2; qH:=aH/4;
%-----------------------------------------------------------------------------------------------
pickup pencircle scaled fP;
- if s=cC: cdw sbp(.05,.95)circ_O;
- ef s=cH: dwv Z_b--Z_w; dw Z_m--Z_o; dwv Z_e--Z_t;
- ef s=cO: dw circ_O;
- ef s=cN: dwv Z_b--Z_w; dwv Z_e--Z_t; dwvs(1.4)(1.4hP,aH)--(aW-1.4hP,0);
- ef s=cS: cdw sbp(.05,.45)circ_O; cdw sbp(.55,.95)circ_O; dw (fW,.3aH){up}..{up}(hP,.7aH);
- ef s=cF: dwh Z_q--Z_u; dwh (0,.45aH)--(fW,.45aH); dw Z_b--Z_r;
- ef s=cP: dwv Z_b--Z_w; dw Z_r--(.65aW,fH){right}..(fW,.7aH)..{left}(.65aW,.44aH)..(hP,.44aH);
+ if s="C": cdw sbp(.05,.95)circ_O;
+ ef s="H": dwv Z_b--Z_w; dw Z_m--Z_o; dwv Z_e--Z_t;
+ ef s="O": dw circ_O;
+ ef s="N": dwv Z_b--Z_w; dwv Z_e--Z_t; dwvs(1.4)(1.4hP,aH)--(aW-1.4hP,0);
+ ef s="S": cdw sbp(.05,.45)circ_O; cdw sbp(.55,.95)circ_O; dw (fW,.3aH){up}..{up}(hP,.7aH);
+ ef s="F": dwh Z_q--Z_u; dwh (0,.45aH)--(fW,.45aH); dw Z_b--Z_r;
+ ef s="P": dwv Z_b--Z_w; dw Z_r--(.65aW,fH){right}..(fW,.7aH)..{left}(.65aW,.44aH)..(hP,.44aH);
ef s="I": dwv Z_x--Z_s; dwh (hW-fP,hP)--(hW+fP,hP); dwh (hW-fP,fH)--(hW+fP,fH);
ef s="l": dwv Z_g--Z_f; dwh Z_s--Z_r; dwh Z_x--Z_z;
ef s="2": cdw (hP,1.3hP)..(.4fW,.35fH)..(fW,.65aH)..Z_s..(hP,.65aH); dwh Z_d--Z_a;
@@ -1127,22 +1159,27 @@ enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def warning_bond(expr a)=
if addA[a]=0:
- warning("A"&decimal(a)&" ( "&fsl(8)(str_tbl[strA[a]])&") has"&fdr(2)(bond_cntA)&" bonds"); fi
+ warning("A"&decimal(a)&" ( "&fsl(8)(str_tbl[strA[a]])&") has"&fdr(2)(bond_cntA)&" bonds");
+ fi
enddef;
%-------------------------------------------------------------------------------------------------
-vardef erase_char(expr s)= sS:="";
+vardef erase_char(expr s)=
+ sS:="";
if (length(s)>=4)and(s<>"COOH"):
for i=1 upto length(s): sC:=subc(i,s); if scan_c(sC,"{}_^+-")=0: sS:=sS&sC; fi endfor sS
- else: s fi
+ else: s
+ fi
enddef;
%-------------------------------------------------------------------------------------------------
-vardef forbidden_to_underbar(expr t)= sS:="";
+vardef forbidden_to_underbar(expr t)= sS:="";
for i=1 upto length(t):
- sC:=subc(i,t); if scan_c(sC," &()[]{}^=;!'+,`~")>0: sS:=sS&"_"; else: sS:=sS&sC; fi endfor sS
+ sC:=subc(i,t); if scan_c(sC,forbiddens)>0: sS:=sS&"_"; else: sS:=sS&sC; fi
+ endfor
+ sS
enddef;
%=================================================================================================
def proc_calc(expr n)=
- num_MW:=num_MI:=tbl_atom_max:=warning_cnt:=hideH_cnt:=0; nE:=parts_emb_start;
+ MW_n:=MI_n:=tbl_atom_max:=warning_cnt:=hideH_cnt:=0; nE:=pcode_emb_start;
for i=1 upto tbl_atom_end: sumA[i]:=0; endfor
for i=1 upto cntA:
knownA:=bond_cntA:=0; nS:=strA[i];
@@ -1176,41 +1213,39 @@ def proc_calc(expr n)=
for k=1 upto tbl_atom[j]:
sumA[tbl_group[j][k]]:=sumA[tbl_group[j][k]]+1;
if tbl_group[j][k]>tbl_atom_max: tbl_atom_max:=tbl_group[j][k]; fi
- endfor fi
- knownA:=1; fi
+ endfor
+ fi
+ knownA:=1;
+ fi
exitif knownA=1;
endfor
- if knownA=0: warning(" Unknown Str("&str_tbl[strA[i]]&") is used "&decimal(i)); fi endfor
+ if knownA=0: warning(" Unknown Str("&str_tbl[strA[i]]&") is used "&decimal(i)); fi
+ endfor
%-------------------------------------------------------------------------------------
- sumA[2]:=sumA[2]+hideH_cnt;
- if (tbl_atom_max=1)and(sumA[2]>0): tbl_atom_max:=2; fi
+ sumA[2]:=sumA[2]+hideH_cnt; if (tbl_atom_max=1)and(sumA[2]>0): tbl_atom_max:=2; fi
for i=1 upto tbl_atom_max:
if sumA[i]>=1:
- num_MW:= num_MW+tbl_atom_wt[i]*sumA[i]; num_MI:= num_MI+tbl_atom_mi[i]*sumA[i];
- fm:=fm&erase_char(tbl_atom_str[i]) if sumA[i]>=2: &decimal(sumA[i]) fi; fi
+ MW_n:= MW_n+tbl_atom_wt[i]*sumA[i]; MI_n:= MI_n+tbl_atom_mi[i]*sumA[i];
+ fm:=fm&erase_char(tbl_atom_str[i]) if sumA[i]>=2: &decimal(sumA[i]) fi;
+ fi
endfor
- mw:=substring(0,8) of decimal(num_MW); MI:=substring(0,10) of decimal(num_MI);
+ mw:=substring(0,8) of decimal(MW_n); MI:=substring(0,10) of decimal(MI_n);
enddef;
%=================================================================================================
def proc_report_out=
- message "["&decimal(fig_num)&"]:"&EN;
file_output:=jobname&"-report.txt";
printf "===========================================================================";
printf " No["&decimal(fig_num)&"],Name<"& EN&">,Category<"&CAT&">,File<"&file_input&">";
- if mc_row>=1:
- printf "---------------------------------------------------------------------------";
- for i=1 upto mc_row: printf (substring(0,mc_indent[i]) of blanks)&mc[i]; endfor
- printf "---------------------------------------------------------------------------";
- printf " Row["&decimal(mc_row)&"],Length["&decimal(length(mc))&"],Commands["&decimal(cnt_cmm)&
- "],&Code["&decimal(parts_cnt[0])&"],Warning["&decimal(warning_cnt)&"]";
- printf "---------------------------------------------------------------------------";
- printf " =["&decimal(cnt_equ)&"]({}=["&decimal(cnt_chgB)&"]), :["&decimal(cnt_cln)&
- "]({}:["&decimal(cnt_chgA)&"]), '()["&decimal(cnt_inline_def)&"]";
- printf " @["&decimal(cnt_at)&"],&["&decimal(cnt_and)&"],<["&decimal(cnt_gtn)&
- "],~["&decimal(cnt_tld)&"],^["&decimal(cnt_hat)&"],`["&decimal(cnt_bqt)&
- "],>["&decimal(cnt_ltn)&
- "],|["&decimal(cnt_bar-cnt_bars)&"],||["&decimal(cnt_bars)&
- "],#["&decimal(cnt_hsh-cnt_hshs)&"],##["&decimal(cnt_hshs)&"]"; fi
+ printf "---------------------------------------------------------------------------";
+ for i=1 upto mc_row: printf (substring(0,mc_indent[i]) of blanks)&mc[i]; endfor
+ printf "---------------------------------------------------------------------------";
+ printf " Row["&decimal(mc_row)&"],Length["&decimal(length(mc))&"],Block"&
+ "["&decimal(block_cnt+1)&"]"&",Code pair["&decimal(pcode_cnt[0])&
+ "],Warning["&decimal(warning_cnt)&"]";
+ printf "---------------------------------------------------------------------------";
+ printf "" for i=EQU,CLN,QES,AMK,AMP,HSH,GTN,BAR,QUT,TLD,HAT,BQT,LTN:
+ if tbl_asc[i]>=1: &" "&char(i)&"["&decimal(tbl_asc[i])&"]" fi
+ endfor ;
printf "---------------------------------------------------------------------------";
printf " Width["&fdr(8)(mol_wd)&"],Height["&fdr(8)(mol_ht)&"],"&
" Shift x["& fdr(8)(minX)&"],Shift y["&fdr(8)(minY)&"]";
@@ -1223,8 +1258,8 @@ def proc_report_out=
printf " A"&fdl(6)(i)&fsl(8)(erase_char(str_tbl[strA[i]]))&
" ("&fdr(10)(round(xpart(posA[i])/blen))&" , "&
fdr(10)(round(ypart(posA[i])/blen))&" ) "&fdr(4)(Bcnt[i])&
- iif(hideH[i]>0,fdr(6)(hideH[i])," ")
- if chargeA[i]<>0: &fdr(4)(chargeA[i]) fi; endfor
+ iif(hideH[i]>0,fdr(6)(hideH[i])," ") if chargeA[i]<>0: &fdr(4)(chargeA[i]) fi;
+ endfor
printf "---------------------------------------------------------------------------";
printf "< NO. >< bond (sdt)><angle +( +- )><length ( pt )>";
for i=1 upto cntB:
@@ -1232,26 +1267,25 @@ def proc_report_out=
nB:=angB[i]; if nB>180: nB:=nB-360; fi
printf " B"&fdl(4)(i)&fdr(3)(sB[i])&" -> "&fdr(3)(eB[i])&
" ("&fdr(3)(bond_num[i])&")"&fdr(8)(round(angB[i]))&
- " ("&fdr(6)(round(nB))&")"&fdr(8)(nC)&" ("&fdr(8)(round(nC*blen))&")"; endfor
+ " ("&fdr(6)(round(nB))&")"&fdr(8)(nC)&" ("&fdr(8)(round(nC*blen))&")";
+ endfor
printf "---------------------------------------------------------------------------";
printf "<atom>( atom wt )[ mi wt ] < cnt > < sum wt >[ sum mi wt ]";
for i=1 upto tbl_atom_max:
if sumA[i]>=1:
printf " "&fsl(5)(erase_char(tbl_atom_str[i]))&
"("&fdr(9)(tbl_atom_wt[i])&")"&"["&fdr(9)(tbl_atom_mi[i])&"]"&" * "&fdr(8)(sumA[i])
- &" "&fdr(7)(tbl_atom_wt[i]*sumA[i])&"["&fdr(12)(tbl_atom_mi[i]*sumA[i])&"]"; fi
+ &" "&fdr(7)(tbl_atom_wt[i]*sumA[i])&"["&fdr(12)(tbl_atom_mi[i]*sumA[i])&"]";
+ fi
endfor
printf " Molecular Weight [Mono Isotopic] = "&fsr(12)(mw)&"["&fsr(12)(MI)&"]";
printf "---------------------------------------------------------------------------";
- printf " Weight Calc: " &mw &" / Input: "
- if MW<>"-": &mw &" / weight gap= " &fdr(9)(num_MW-scantokens(MW)) fi;
- printf " Fomula Calc: "&fm
- if FM<>"-": &" / Input: "&FM&" ( "& iif(fm=FM,"MACTCH )","NOT MACTCH )") fi;
+ printf " Weight Calc: "&mw if MW<>"-": &" - Input: "&MW&" = "&fdr(9)(MW_n-scantokens(MW)) fi;
+ printf " Fomula Calc: "&fm if FM<>"-": &" "&iif(fm=FM,"=","<>")&" Input: "&FM fi;
printf "===========================================================================";
enddef;
%=================================================================================================
def proc_mol_out(expr n)=
- message "["&decimal(fig_num)&"]:"&EN;
if EN<>"-": EN_:=forbidden_to_underbar(EN); fi
file_output:="m"&fit_zero(fig_num)&"-"&EN_&".mol";
%-V2000---------------------------------------------------------------------------------------
@@ -1264,7 +1298,8 @@ def proc_mol_out(expr n)=
endfor
for i=1 upto cntB:
if lineB[i]<>0: printf fdr(3)(sB[i])&fdr(3)(eB[i])&fdr(3)(bond_type(lineB[i]))&
- fdr(3)(bond_stereo(lineB[i]))&" 0 0"; fi
+ fdr(3)(bond_stereo(lineB[i]))&" 0 0";
+ fi
endfor
printf "M END";
%-V3000---------------------------------------------------------------------------------------
@@ -1284,21 +1319,24 @@ def proc_mol_out(expr n)=
if lineB[i]<>0:
printf "M V30 "&decimal(i)&" "&decimal(bond_type(lineB[i]))&
" "&decimal(sB[i])&" "&decimal(eB[i])
- if bond_stereo(lineB[i])<>0: &" CFG="&decimal(bond_config(lineB[i])) fi; fi
+ if bond_stereo(lineB[i])<>0: &" CFG="&decimal(bond_config(lineB[i])) fi;
+ fi
endfor
printf "M V30 END BOND"; printf "M V30 END CTAB"; printf "M END"; fi
enddef;
%=================================================================================================
def proc_mc_out=
- message "["&decimal(fig_num)&"]:"&EN;
file_output:="temp-mc.aux";
if mc_length<100:
nN:=split_str(mc,",")(arg_s); nA:=0; temps:="";
for i=1 upto nN:
if i=nN: temps:=temps&arg_s[i]; printf temps;
ef at_char[i+1]-nA>mc_length: nA:=at_char[i]; printf temps&arg_s[i]&","; temps:="";
- else: temps:=temps&arg_s[i]&","; fi endfor
- else: for i=1 upto mc_row: printf (substring(0,mc_indent[i]) of blanks)&mc[i]; endfor fi
+ else: temps:=temps&arg_s[i]&",";
+ fi
+ endfor
+ else: for i=1 upto mc_row: printf (substring(0,mc_indent[i]) of blanks)&mc[i]; endfor
+ fi
printf EOF;
enddef;
%=================================================================================================
@@ -1312,19 +1350,21 @@ vardef bond_config(expr n)=
if (n=wf)or(n=zb)or(n=bd): 1 ef (n=zf)or(n=wb)or(n=dt): 3 ef n=wv: 2 else: 0 fi enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vardef TA(expr s,WT,MI)=
- str_cnt:=str_cnt+1; tbl_cnt:=tbl_cnt+1; parts_num:=parts_num+1;
- parts_com[parts_num][1]:=_set_atom; parts_par[parts_num][1]:=str_cnt; parts_cnt[parts_num]:=1;
+ str_cnt:=str_cnt+1; tbl_cnt:=tbl_cnt+1; pcode_num:=pcode_num+1;
+ pcode_com[pcode_num][1]:=_set_atom; pcode_par[pcode_num][1]:=str_cnt; pcode_cnt[pcode_num]:=1;
str_tbl[str_cnt]:=tbl_atom_str[tbl_cnt]:=s; tbl_atom[tbl_cnt]:=0;
- tbl_atom_wt[tbl_cnt]:=WT; tbl_atom_mi[tbl_cnt]:=MI; parts_num enddef;
+ tbl_atom_wt[tbl_cnt]:=WT; tbl_atom_mi[tbl_cnt]:=MI; pcode_num
+enddef;
%-------------------------------------------------------------------------------------------------
vardef TB(expr s)(text t)=
- str_cnt:=str_cnt+1; tbl_cnt:=tbl_cnt+1; parts_num:=parts_num+1;
- parts_com[parts_num][1]:=_set_atom; parts_par[parts_num][1]:=str_cnt; parts_cnt[parts_num]:=1;
+ str_cnt:=str_cnt+1; tbl_cnt:=tbl_cnt+1; pcode_num:=pcode_num+1;
+ pcode_com[pcode_num][1]:=_set_atom; pcode_par[pcode_num][1]:=str_cnt; pcode_cnt[pcode_num]:=1;
str_tbl[str_cnt]:=tbl_atom_str[tbl_cnt]:=s; tbl_atom[tbl_cnt]:=0;
- for list=t: tbl_group[tbl_cnt][incr tbl_atom[tbl_cnt]]:=list-parts_emb_start; endfor parts_num
+ for list=t: tbl_group[tbl_cnt][incr tbl_atom[tbl_cnt]]:=list-pcode_emb_start; endfor
+ pcode_num
enddef;
%=================================================================================================
-parts_int:=parts_emi_start; parts_num:=parts_emb_start;
+pcode_int:=pcode_emi_start; pcode_num:=pcode_emb_start;
%-------------------------------------------------------------------------------------------------
C:= TA("C" ,12.0107, 12.0000000); H:= TA("H" , 1.00794, 1.00782503223);
D:= TA("D" ,2.012, 2.01410177812); Ag:=TA("{Ag}",107.868, 106.905095);
@@ -1353,153 +1393,129 @@ U:= TA("U", 238.0289, 238.05079); V:= TA("V", 50.9415, 50.943957);
W:= TA("W", 183.85, 181.948225); Zn:=TA("{Zn}",65.409, 63.92914201);
tbl_atom_end:=tbl_cnt;
%-------------------------------------------------------------------------------------------------
-CH3:=TB("C{H_3_}")(C,H,H,H); CH2:=TB("C{H_3_}")(C,H,H); CN:=TB("CN")(C,N); OH:=TB("OH")(O,H);
-COOH:=TB("COOH")(C,O,O,H); COONa:=TB("COO{Na}")(C,O,O,Na); CHO:=TB("CHO")(C,H,O);
-NO:=TB("NO")(N,O); NO2:=TB("N{O_2_}")(N,O,O); NH2:=TB("N{H_2_}")(N,H,H);
-SH:= TB("SH")(S,H); SO2H:=TB("S{O_2_}H")(S,O,O,H); SO3H:=TB("S{O_3_}H")(S,O,O,O,H);
-ONa:=TB("O{Na}")(O,Na); SO3Na:=TB("S{O_3_}{Na}")(S,O,O,O,Na);
+if sw_expand=0:
+ CH3:=TB("C{H_3_}")(C,H,H,H); CH2:=TB("C{H_3_}")(C,H,H); CN:=TB("CN")(C,N); OH:=TB("OH")(O,H);
+ COOH:=TB("COOH")(C,O,O,H); COONa:=TB("COO{Na}")(C,O,O,Na); CHO:=TB("CHO")(C,H,O);
+ NO:=TB("NO")(N,O); NO2:=TB("N{O_2_}")(N,O,O); NH2:=TB("N{H_2_}")(N,H,H);
+ SH:= TB("SH")(S,H); SO2H:=TB("S{O_2_}H")(S,O,O,H); SO3H:=TB("S{O_3_}H")(S,O,O,O,H);
+ ONa:=TB("O{Na}")(O,Na); SO3Na:=TB("S{O_3_}{Na}")(S,O,O,O,Na);
+fi
%-------------------------------------------------------------------------------------------------
-tbl_group_end:=tbl_cnt; parts_atom_end:=parts_num;
+tbl_group_end:=tbl_cnt; pcode_atom_end:=pcode_num;
%=================================================================================================
for i=3 upto 20: ?[i]:='((_com,_len_ss),(_get_len,_ring_len),<((-180 DIV i)-90)
- for j==2 upto i:: ,(360 DIV i) endfor,(_cyc_sB,1-i),(_com,_len_ee)); endfor
-Ph:=Ph1:='(?6,-2=dl,-4=dl,-6=dl); Ph2:='(?6,-1=dl,-3=dl,-5=dl);
-for i=5,6,7,8: for j=11 upto 15: ?[i][j]:='(); endfor endfor
+ for j==2 upto i:: ,(360 DIV i) endfor,(_cyc_sB,1-i),(_com,_len_ee));
+endfor
+Ph:=Ph1:='(?6,-2=dl,-4=dl,-6=dl); Ph2:='(?6,-1=dl,-3=dl,-5=dl); Me:='();
+for i=5,6,7,8: for j=11 upto 15: ?[i][j]:='((i,j)); endfor endfor
%-------------------------------------------------------------------------------------------------
-!:=!1:='((_mk_bond,_arrange_ang)); !!:='(!~db); !!!:='(!~tm);
+!:=!1:='((_mk_bond,_arrange_ang)); !!:='(!~db); !!!:='(!~tm); NH:='(N,/H~nl);
for i==2 upto 20:
- ![i]:='((_com,_len_ss),(_get_len,_tmp_len),! for j==2 upto i::,! endfor ,(_com,_len_ee)); endfor
-Me:='(); Et:='(!); iPr:=?!:='(/_,!); ?!2:='(/_,!2); tBu:=??!:='(/_,/_^60,60);
-!?:='(!,/_); !?!:='(!,/_,!); n_:='((_set_add,a_minus)); p_:='((_set_add,a_plus));
+ ![i]:='((_com,_len_ss),(_get_len,_tmp_len),! for j==2 upto i::,! endfor ,(_com,_len_ee));
+endfor
+?!:='(/_,!); ?!!:='(/_,!!); ?!2:='(/_,!2); ??!:='(/_,/_^60,60); ??:='(/_^35,/_^-35);
+!?:='(!,/_); !?!:='(!?,!); !??!:='(!,??,!); ?2:='(/!); !?2:='(!,?2); ?2!:='(?2,!); !?2!:='(!?2,!);
+n_:='((_set_add,MIS)); p_:='((_set_add,PLS));
zero_wf:='(0~wf); zero_zf:='(0~zf); zero_dm:='(0~dm); zero_wv:='(0~wv);
mark_adress:='((_com,_mark)); reset_adress:='((_com,_moff)); reset_length:='((_com,_len_e));
%-------------------------------------------------------------------------------------------------
-NH:='(N,/H~nl); N!:='(N,/_); N!2:='(N,/!); SO:='(S,//O); SOO:='(S,//O^-35,//O^35);
-O!:='(O,!); O!2:='(O,!,!); O!3:='(O,!,!,!); O!?!:='(O,!,?!); O!??!:='(O,!,??!); OPh:='(O,!,Ph);
-S!:='(S,!); S!2:='(S,!,!); S!3:='(S,!,!,!); S!?!:='(S,!,?!); S!??!:='(S,!,??!);
+if sw_expand=1:
+ CH3:='(/H,/H^60,/H^-60); NH:='(N,/H); NH2:='(N,/H^60,/H^-60); NO2:='(N,//O^60,//O^-60);
+ OH:='(O,!,H); NO:='(N,//O); CONH2:='(//O,!,NH2); SH:='(S,!,H); SO2H:='(S,//O^60,/OH^-60);
+ SO3H:='(S,/OH,//O^60,//O^-60); CHO:='(//O^-60,/H^60); COOH:='(//O^-60,/OH^60); CN:='(!~tm,N);
+ ONa:='(O,!,Na); SO3Na:='(S,/ONa,//O^60,//O^-60);
+fi
+%-------------------------------------------------------------------------------------------------
+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);
%-------------------------------------------------------------------------------------------------
-COO:='(//O,!,O); COO!:='(COO,!); COO!2:='(COO,!,!); COO!??:='(COO,!,?!); COO!3:='(COO,!,!,!);
-CO!:='(//O,!); CO!2:='(//O,!,!); CO!3:='(//O,!,!,!); OCO!:='(O,!,//O,!);
-N?!:='(N,!,@-2,0); N?!2:='(N!,!,!); NH!:='(NH,!); NH!2:='(NH,!,!); NH!3:='(NH,!,!,!);
-NH!?!:='(NH,!,?!); NHCO!:='(NH,!,//O,!); CONH2:='(//O,!,NH2); ??:='(/_^35,/_^-35);
+N!:='(N,!); N?:='(N,/_); N!2:='(N,!3); N!2:='(N,!3); !N:='(!,N);
+N?!:='(N,?!); N?2:='(N,?2); N?2!:='(N?2,!); N?!2:='(N,?!2);
+S?O:='(S,//O); S?O!:='(S?O,!); ?O?O:='(//O^-35,//O^35); S?O?O:='(S,?O?O); S?O?O!:='(S?O?O,!);
+O!:='(O,!); O!2:='(O,!2); O!3:='(O,!3); S!:='(S,!); S!2:='(S,!2); S!3:='(S,!3);
%-------------------------------------------------------------------------------------------------
-!OH:='(!,OH); !SH:='(!,SH); !NH2:='(!,NH2); !CO!:='(!,//O,!); !CO!2:='(!,CO!2); !CO!3:='(!,CO!3);
+?O:='(//O); ?O!:='(?O,!); ?O!2:='(?O,!2); ?O!3:='(?O,!3); !?O:='(!,?O); !?O!:='(!,?O!);
+NH!:='(NH,!); NH!2:='(NH,!2); !NH!:='(!,NH!); ?NH2:='(/NH2); ?NH:='(//NH);
+%-------------------------------------------------------------------------------------------------
+!OH:='(!,OH); !SH:='(!,SH); !NH2:='(!,NH2); !S?O:='(!,S?O); !O:='(!,O);
!O!:='(!,O!); !O!2:='(!,O!2); !O!3:='(!,O!3); !S!:='(!,S!); !S!2:='(!,S!2); !S!3:='(!,S!3);
-!NH!:='(!,NH!); !NH!2:='(!,NH!2); !NH!3:='(!,NH!3);
-!COOH:='(!,COOH); !COO!:='(!,COO!); !COO!2:='(!,COO!2); !CH3:='(!,CH3); !CN:='(!,CN);
-!CHO:='(!,CHO); !NO2:='(!,NO2); !Cl:='(!,Cl); !Br:='(!,Br); !F:='(!,F);
+!COOH:='(!,COOH); ?COOH:='(/COOH); !CH3:='(!,CH3); !CN:='(!,CN); !CHO:='(!,CHO); !NO2:='(!,NO2);
+!Cl:='(!,Cl); !Br:='(!,Br); !F:='(!,F); !CF3:='(!,CF3); !CCl3:='(!,CCl3);
!?3:='(!,?3); !?4:='(!,?4); !?5:='(!,?5); !?6:='(!,?6); !?7:='(!,?7); !?8:='(!,?8); !Ph:='(!,Ph);
+?H:='(/H); ?F:='(/F); ?Cl:='(/Cl); ?OH:='(/OH); !?OH:='(!,?OH); ?OH!:='(?OH,!);
%-------------------------------------------------------------------------------------------------
-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);
-%-------------------------------------------------------------------------------------------------
-lr:='(0,0,0,60 for i==1 upto 10:: ,-60,60 endfor);
+lr:='(0,0,0,60 for i==1 upto 10:: ,-60,60 endfor);
rl:='(0,0,0,-60 for i==1 upto 10:: ,60,-60 endfor);
%-------------------------------------------------------------------------------------------------
-R:='("R"); R1:='("{R^1^}"); R2:='("{R^2^}"); R3:='("{R^3^}"); R4:='("R^4^"); R5:='("{R^5^}");
-R6:='("R6"); R7:='("{R^7^}"); R8:='("{R^8^}"); R9:='("{R^9^}"); R10:='("R^10^"); R11:='("{R^11^}");
+R:='("R"); R1:='("{R^1^}"); R2:='("{R^2^}"); R3:='("{R^3^}"); R4:='("R^4^"); R5:='("{R^5^}");
+R6:='("R6"); R7:='("{R^7^}"); R8:='("{R^8^}"); R9:='("{R^9^}"); R10:='("R^10^");R11:='("{R^11^}");
%-------------------------------------------------------------------------------------------------
hexose_hp:='(#1.4,-30~wf_r,30~bd_r`1,30~wb_r,120,O,30,&1,##);
Pyranose_hp:='(#1.4,-35~wf_r,35~bd_r`1,30~wb_r,130`1.66,O,&1,##);
-%-------------------------------------------------------------------------------------------------
-xCH3:='(/H,/H^60,/H^-60); xNH:='(N,/H~nl); xNH2:='(N,/H~nl^60,/H~nl^-60);
-xNO2:='(N,//O^60,//O^-60); xOH:='(O,/H~nl); xNO:='(N,//O); xCONH2:='(//O,!,xNH2);
-xSO2H:='(S,//O^60,/OH^-60); xSO3H:='(S,/OH,//O^60,//O^-60);
-xCHO:='(//O^-60,/H^60); xCOOH:='(//O^-60,/xOH^60); xCN:='(/N~tm); xSH:='(S,/H~nl);
-!xOH:='(!,xOH); !xCHO:='(!,xCHO); !xCOOH:='(!,xCOOH); !xCH3:='(!,xCH3); !xCN:='(!,xCN);
-!xNH2:='(!,xNH2); !xNO2:='(!,xNO2); !xSH:='(!,xSH);
%=================================================================================================
init_par(parameter_list);
%-------------------------------------------------------------------------------------------------
-%%%%message "parts_emb =" & decimal(parts_emb_start) &" => " & decimal(parts_num);
-%%%%message "parts_emi =" & decimal(parts_emi_start) &" => " & decimal(parts_int);
-%-------------------------------------------------------------------------------------------------
-def expand_set=
- CH3:=xCH3; NH:=xNH; NH2:=xNH2; NO:=xNO; NO2:=xNO2; OH:=xOH; CHO:=xCHO; COOH:=xCOOH; CN:=xCN;
- CONH2:=xCONH2; xSH:=xSH; SO2H:=xSO2H; SO3H:=xSO3H; !SH:=!xSH;
- !CH3:=!xCH3; !OH:=!xOH; !NH2:=!xNH2; !CHO:=!xCHO; !COOH:=!xCOOH; !CN:=!xCN; !NO2:=!xNO2; enddef;
+for i=pcode_emb_start+1 upto pcode_num: pcode_all:=pcode_all+pcode_cnt[i]; endfor
+message "pcode_emb =" & decimal(pcode_emb_start) &" => " & decimal(pcode_num) &
+ " [ " & decimal(pcode_all) & " ]";
+message "pcode_emi =" & decimal(pcode_emi_start) &" => " & decimal(pcode_int);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vardef checkm(expr s)=
- save mc_char,err_cnt,char_cnt,f_depth,cnt_prn_s,cnt_prn_e,cnt_brc_s,cnt_brc_e,cnt_brk_s,
- cnt_brk_e,cmm_adr;
- string err_str[],err_type[];
- numeric mc_char[],err_adr[],err_code[],cmm_adr[];
- err_cnt:=char_cnt:=code_cnt:=f_depth:=cnt_cmm:=cnt_chgA:=cnt_chgB:=0;
- err_type[0]:="no mc-row "; err_type[1]:=" '(' > ')' "; err_type[2]:=" '(' < ')' ";
- err_type[3]:=" '{' > '}' "; err_type[4]:=" '{' < '}' "; err_type[5]:=" '[' > ']' ";
- err_type[6]:=" '[' < ']' "; err_type[7]:="missing arg"; err_type[8]:="extra arg ";
+ save mc_char,mc_adr,mc_asc,char_cnt,lens,f_depth;
+ string err_type[];
+ numeric mc_char[],mc_asc[],mc_adr[];
+ err_cnt:=char_cnt:=block_cnt:=f_depth:=0; nA:=1; lens:=length(s);
+ err_type[0]:="no mc-row "; err_type[1]:="mismatch () "; err_type[2]:="mismatch {} ";
+ err_type[3]:="mismatch [] "; err_type[4]:="missing arg "; err_type[5]:="extra arg ";
%---------------------------------------------------------------------------------------------
if mc_row>=1:
- for i=1 upto length(s):
- tempc:=subc(i,s); if tempc<>" ": mc_char[incr char_cnt]:=ASCII(tempc); fi endfor
- mc_char[0]:=mc_char[char_cnt+1]:=mc_char[char_cnt+2]:=a_cmm;
- %-- argument missing chkeck --------------------------------------------------------------
- cnt_prn_s:=cnt_prn_e:=cnt_brc_s:=cnt_brc_e:=cnt_brk_s:=cnt_brk_e:=cnt_inline_def:=0;
- cnt_at:=cnt_cmm:=cnt_and:=cnt_gtn:=cnt_equ:=cnt_cln:=cnt_bar:=cnt_bars:=cnt_tld:=cnt_hat:=0;
- cnt_bqt:=cnt_ltn:=cnt_hsh:=cnt_hshs:=f_depth:=nA:=0;
+ for i=1 upto 128: tbl_asc[i]:=0; endfor
+ for i=1 upto lens: mc_char[i]:=ASCII(subc(i,s)); endfor
forever:
- nA:=nA+1; nB:=mc_char[nA-1]; nC:=mc_char[nA]; nD:=mc_char[nA+1];
- if nC=a_cmm: if f_depth=0: cmm_adr[incr cnt_cmm]:=nA; fi
- ef nC=a_ast:
- if nD=a_sls:
- if mc_char[nA+2]=a_ast: if mc_char[nA+3]=a_cmm: proc_err(7,nA) nA:=nA+2; fi % */* x
- ef mc_char[nA+2]=a_cmm: proc_err(7,nA) nA:=nA+1; fi % */ x
- ef nD=a_ast: if mc_char[nA+2]=a_cmm: proc_err(7,nA) nA:=nA+1; fi fi % ** x
- ef nC=a_sls: if nD=a_sls: if mc_char[nA+2]=a_cmm: proc_err(7,nA) nA:=nA+1; fi % // x
- ef nD=a_ast: if mc_char[nA+2]=a_cmm: proc_err(7,nA) nA:=nA+1; fi % /* x
- ef nD=a_cmm: proc_err(7,nA) fi % / x
- ef nC=a_hsh: cnt_hsh:=cnt_hsh+1; % #+##
- if nD=a_hsh: cnt_hshs:=cnt_hshs+1; nA:=nA+1; % ##
- ef nD=a_cmm: proc_err(7,nA) fi if nB<>a_cmm: proc_err(8,nA) fi % a # x
- ef nC=a_dol: if nD=a_cmm: proc_err(7,nA) fi % $ x
- ef nC=a_equ: cnt_equ:=cnt_equ+1;
- if nD= a_cmm: proc_err(7,nA) fi if nB= a_cmm: proc_err(7,nA) fi % x = x
- ef nC=a_cln: cnt_cln:=cnt_cln+1;
- if nD= a_cmm: proc_err(7,nA) fi if nB= a_cmm: proc_err(7,nA) fi % x : x
- ef nC=a_amk: cnt_at:=cnt_at+1;
- if nD= a_cmm: proc_err(7,nA) fi if nB<>a_cmm: proc_err(8,nA) fi % a @ x
- ef nC=a_and: cnt_and:=cnt_and+1;
- if nD= a_cmm: proc_err(7,nA) fi if nB<>a_cmm: proc_err(8,nA) fi % a & x
- ef nC=a_gtn: cnt_gtn:=cnt_gtn+1;
- ef nC=a_ltn: cnt_ltn:=cnt_ltn+1;
- if nD= a_cmm: proc_err(7,nA) fi if nB= a_cmm: proc_err(7,nA) fi % x > x
- ef nC=a_tld: cnt_tld:=cnt_tld+1;
- if nD= a_cmm: proc_err(7,nA) fi if nB= a_cmm: proc_err(7,nA) fi % x ~ x
- ef nC=a_hat: cnt_hat:=cnt_hat+1;
- if nD= a_cmm: proc_err(7,nA) fi if nB= a_cmm: proc_err(7,nA) fi % x ^ x
- ef nC=a_bqt: cnt_bqt:=cnt_bqt+1;
- if nD= a_cmm: proc_err(7,nA) fi if nB= a_cmm: proc_err(7,nA) fi % x ` x
- ef nC=a_bar: cnt_bar:=cnt_bar+1; % |+||
- if nD= a_bar: cnt_bars:=cnt_bars+1; if mc_char[nA+2]=a_bar: nA:=nA+1; % ||
- ef mc_char[nA+2]<>a_cmm: proc_err(8,nA) fi % | a
- if nB<>a_cmm: proc_err(8,nA) fi fi % a |
- ef nC=a_prn_s: if nD= a_cmm: proc_err(7,nA) fi % ( x
- cnt_prn_s:=cnt_prn_s+1; f_depth:=1;
- if nB=a_qut: cnt_inline_def:=cnt_inline_def+1; fi
- ef nC=a_prn_e: cnt_prn_e:=cnt_prn_e+1; f_depth:=0;
- ef nC=a_brc_s: if nD= a_cmm: proc_err(7,nA) fi cnt_brc_s:=cnt_brc_s+1; f_depth:=1; % { x
- ef nC=a_brc_e: if nD= a_cmm: proc_err(7,nA) fi cnt_brc_e:=cnt_brc_e+1; f_depth:=0; % } x
- if nD=a_cln: cnt_chgA:=cnt_chgA+1; ef nD=a_equ: cnt_chgB:=cnt_chgB+1; fi
- ef nC=a_brk_s: if nD= a_cmm: proc_err(7,nA) fi cnt_brk_s:=cnt_brk_s+1; f_depth:=1; % [ x
- ef nC=a_brk_e: if nB= a_cmm: proc_err(7,nA) fi cnt_brk_e:=cnt_brk_e+1; f_depth:=0; % x ]
+ temps:=substring (nA-1,nA) of s;
+ if (temps<>",")and(temps<>" "): nF:=0;
+ for j=1 upto rw_cnt: nC:=lenw[j]-1;
+ if substring (nA-1,nA+nC) of s=rw[j]:
+ for k=1 upto nC: mc_char[nA]:=j; mc_char[nA+k]:=BLK; endfor
+ nF:=1; nA:=nA+nC;
+ fi
+ exitif nF=1;
+ endfor
+ fi
+ nA:=nA+1; exitif nA>=lens;
+ endfor
+ for i=1 upto lens:
+ if mc_char[i]<>BLK: mc_asc[incr char_cnt]:=mc_char[i]; mc_adr[char_cnt]:=i; fi
+ endfor
+ mc_asc[0]:=mc_asc[char_cnt+1]:=CMA;
+ %-- argument check -------------------------------------------------------------------------
+ for i=1 upto char_cnt:
+ nA:=mc_asc[i-1]; nB:=mc_asc[i]; nC:=mc_asc[i+1]; tbl_asc[nB]:=tbl_asc[nB]+1;
+ if nB=CMA: if f_depth=0: block_cnt:=block_cnt+1; fi
+ ef (nB=EQU)or(nB=CLN)or(nB=HAT)or(nB=BQT)or(nB=TLD)or(nB=LTN): % =,:,^,`,~,>
+ if (nA=CMA)or(nC=CMA): proc_err(4,i) fi
+ ef (nB=AMK)or(nB=AMP)or(nB=GTN)or(nB=HSH): % @,&,<,#
+ if nA<>CMA: proc_err(5,nB) fi if nC=CMA: proc_err(4,i) fi
+ ef (nB=SLS)or((nB>=7)and(nB<=11)): % /,*/*,//,/*,*/,**
+ if (nA<>CMA)and(nA<>CLN)and(nA<>PRS): proc_err(5,i) fi
+ if nC=CMA: proc_err(4,i) fi
fi
- exitif nA>=char_cnt+1;
+ if (nB=PRS)or(nB=BRS): f_depth:=f_depth+1; ef (nB=PRE)or(nB=BRE): f_depth:=f_depth-1; fi
endfor
%-- brackets balance check -----------------------------------------------------------------
- if cnt_prn_s>cnt_prn_e: proc_err(1,0) ef cnt_prn_s<cnt_prn_e: proc_err(2,0) fi
- if cnt_brc_s>cnt_brc_e: proc_err(3,0) ef cnt_brc_s<cnt_brc_e: proc_err(4,0) fi
- if cnt_brk_s>cnt_brk_e: proc_err(5,0) ef cnt_brk_s<cnt_brk_e: proc_err(6,0) fi
+ if tbl_asc[PRS]<>tbl_asc[PRE]: proc_err(1,0) fi % mismatch ()
+ if tbl_asc[BRS]<>tbl_asc[BRE]: proc_err(2,0) fi % mismatch {}
+ if tbl_asc[BKS]<>tbl_asc[BKE]: proc_err(3,0) fi % mismatch []
else: proc_err(0,0) fi
%---------------------------------------------------------------------------------------------
- for i=1 upto err_cnt:
- message "*"&fdr(3)(i)&" "&err_type[err_code[i]]&fdr(4)(err_adr[i])&" '"&err_str[i]&"'";
- endfor
%%%%%%% err_cnt>0: readstring;
err_cnt
enddef;
%-------------------------------------------------------------------------------------------------
-def proc_err(expr e,n)= err_adr[incr err_cnt]:=n; err_code[err_cnt]:=e;
- if e<=6: err_str[err_cnt]:=" "; else: err_str[err_cnt]:=substring(n-3,n+2) of mc; fi
+def proc_err(expr e,n)=
+ err_cnt:=err_cnt+1;
+ message "["&decimal(fig_num)&"]:"&err_type[e]
+ if n>=1: &"("&fdr(3)(n)&") "&substring(mc_adr[n]-2,mc_adr[n]+3) of mc fi ;
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def savem(expr s)=
@@ -1519,8 +1535,7 @@ def loadm(text s)=
numeric row_cnt[],order[],order_tbl[],filter_sign[],filter_p[];
lines:=f_mcf:=mc_row:=info_cnt:=filter_cnt:=lib_unit_cnt:=0; unit_cnt:=1;
file_input:=default_library;
- sign_s[1]:="="; sign_s[2]:="<>"; sign_s[3]:="<"; sign_s[4]:=">"; sign_s[5]:="<=";
- sign_s[6]:=">=";
+ sign_s1:="="; sign_s2:="<>"; sign_s3:="<"; sign_s4:=">"; sign_s5:="<="; sign_s6:=">=";
%-----------------------------------------------------------------------------------------------
for list=s:
at_colon:=scan_c(":",list); at_equal:=scan_c("=",list); at_less:=scan_c("<",list);
@@ -1532,20 +1547,17 @@ def loadm(text s)=
else: sign_at:=at_equal; sign_n:=1; at_n:=1; fi
ef at_greater>=2: if (at_greater-1)=at_less: sign_at:=at_greater; sign_n:=2; at_n:=2;
else: sign_at:=at_greater; sign_n:=4; at_n:=1; fi
- ef at_less>=2: sign_at:=at_less; sign_n:=3; at_n:=1;
- fi
+ ef at_less>=2: sign_at:=at_less; sign_n:=3; at_n:=1; fi
sT:=substring(0,sign_at-at_n) of list; sV:=substring(sign_at,length(list)) of list;
%---------------------------------------------------------------------------------------------
if sign_n=0:
if sT="f": if scan_c(".",sV)=0: file_input:=sV&".mcf"; else: file_input:=sV; fi
ef sT="a": key_s:=sV; sort_oder:=0;
- ef sT="d": key_s:=sV; sort_oder:=1;
- fi
+ ef sT="d": key_s:=sV; sort_oder:=1; fi
else:
filter_tag[incr filter_cnt]:=sT; filter_sign[filter_cnt]:=sign_n;
if (sign_n>=3)and(is_num(sV)=1): filter_var[filter_cnt]:=fix_num(sV);
- else: filter_var[filter_cnt]:=sV;
- fi
+ else: filter_var[filter_cnt]:=sV; fi
fi
endfor
%-----------------------------------------------------------------------------------------------
@@ -1580,8 +1592,7 @@ def loadm(text s)=
if filter_n=1: if key_s<>"": sort_tbl[unit_cnt]:=sort_s; fi unit_cnt:=unit_cnt+1; fi
ef (firstc=":")or(firstc="="): f_mcf:=1; mc_row:=1;
ef (firstc<>"%")or(sw_comment=1):
- if f_mcf=1: mc_row:=mc_row+1;
- else: info[unit_cnt]:=info_cnt:=split_str(temps,";")(arg_s);
+ if f_mcf=1: mc_row:=mc_row+1; else: info[unit_cnt]:=info_cnt:=split_str(temps,";")(arg_s);
fi
fi
fi
@@ -1594,22 +1605,22 @@ def loadm(text s)=
for i=1 upto filter_cnt:
message "* Filter("&decimal(i)&"): "&filter_tag[i]&" "&sign_s[filter_sign[i]]&filter_var[i];
endfor
- if key_s<>"":
- message "* Sort key : "&key_s&iif(sort_oder=0," (ascending)"," (descending)");
+ if key_s<>"": message "* Sort key : "&key_s&iif(sort_oder=0," (ascending)"," (descending)");
fi
fi
- message "";
%-----------------------------------------------------------------------------------------
if key_s<>"":
for i=1 upto unit_cnt: order[i]:=0; endfor
for i=1 upto unit_cnt:
if sort_oder=0: temps:="~";
for j=1 upto unit_cnt:
- if order[j]=0: if sort_tbl[j]<temps: temps:=sort_tbl[j]; min_n:=j; fi fi endfor
+ if order[j]=0: if sort_tbl[j]<temps: temps:=sort_tbl[j]; min_n:=j; fi fi
+ endfor
order[min_n]:=i; order_tbl[i]:=min_n;
ef sort_oder=1: temps:=" ";
for j=1 upto unit_cnt:
- if order[j]=0: if sort_tbl[j]>temps: temps:=sort_tbl[j]; max_n:=j; fi fi endfor
+ if order[j]=0: if sort_tbl[j]>temps: temps:=sort_tbl[j]; max_n:=j; fi fi
+ endfor
order[max_n]:=i; order_tbl[i]:=max_n;
fi
endfor
@@ -1636,27 +1647,39 @@ enddef;
vardef fix_num(expr s)=
sS:=s; nN:=scan_c(".",sS);
if nN=0: sS:=fsr(4)(sS); ef nN=1: sS:=" 0"&sS;
- ef nN=2: sS:=" "&sS; ef nN=3: sS:=" "&sS; ef nN=4: sS:=" "&sS; fi sS enddef;
+ ef nN=2: sS:=" "&sS; ef nN=3: sS:=" "&sS; ef nN=4: sS:=" "&sS;
+ fi
+ sS
+enddef;
%-------------------------------------------------------------------------------------------------
vardef is_num(expr s)=
for i=1 upto length(s):
- if ((subc(i,s)>="0")and(subc(i,s)<="9"))or(subc(i,s)="."): nN:=1; else: nN:=0; fi endfor nN
+ if ((subc(i,s)>="0")and(subc(i,s)<="9"))or(subc(i,s)="."): nN:=1; else: nN:=0; fi
+ endfor
+ nN
enddef;
-%--------------------------------------------------------------------------------------------------
+%-------------------------------------------------------------------------------------------------
vardef scan_bit(expr n,b)= if b>=1: odd(floor(n/b)) else: odd(floor((frac n)/b)) fi enddef;
-%--------------------------------------------------------------------------------------------------
+%-------------------------------------------------------------------------------------------------
vardef scan_char(expr c,s,d,n)=
- nN:=0; if d=0: for i=n upto length(s): if subc(i,s)=c: nN:=i; fi exitif nN>0; endfor
- ef d=1: for i=n upto length(s): if subc(i,s)<>c: nN:=i; fi exitif nN>0; endfor
- ef d=-1: for i=length(s) downto n: if subc(i,s)<>c: nN:=i; fi exitif nN>0; endfor fi nN
+ nN:=0;
+ if d=0: for i=n upto length(s): if subc(i,s)=c: nN:=i; fi exitif nN>0; endfor
+ ef d=1: for i=n upto length(s): if subc(i,s)<>c: nN:=i; fi exitif nN>0; endfor
+ ef d=-1: for i=length(s) downto n: if subc(i,s)<>c: nN:=i; fi exitif nN>0; endfor
+ fi
+ nN
enddef;
+%-------------------------------------------------------------------------------------------------
def scan_c(expr c,s)= scan_char(c,s,0,1) enddef;
%-------------------------------------------------------------------------------------------------
vardef split_str(expr s,c)(suffix v)=
at_char[0]:=nN:=0; for i=1 upto length(s): if subc(i,s)=c: at_char[incr nN]:=i; fi endfor
nN:=nN+1; at_char[nN]:=length(s)+1;
- for i=1 upto nN: v[i]:=substring (at_char[i-1],at_char[i]-1) of s; endfor nN enddef;
+ for i=1 upto nN: v[i]:=substring (at_char[i-1],at_char[i]-1) of s; endfor
+ nN
+enddef;
%-------------------------------------------------------------------------------------------------
vardef get_tag_var(expr s)(suffix t,v)=
- nN:=scan_c(":",s); t:=substring(0,nN-1) of s; v:=substring(nN,length(s)) of s; enddef;
+ nN:=scan_c(":",s); t:=substring(0,nN-1) of s; v:=substring(nN,length(s)) of s;
+enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%