summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mp
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/metapost/mcf2graph/mcf2graph.mp')
-rw-r--r--Master/texmf-dist/metapost/mcf2graph/mcf2graph.mp1047
1 files changed, 549 insertions, 498 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mp b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mp
index 2c91c108a31..c7ece3e2467 100644
--- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mp
+++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mp
@@ -1,5 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% mcf2graph ver 5.15 Copyright (c) 2013-2024 Akira Yamaji
+% mcf2graph ver 5.16 Copyright (c) 2013-2025 Akira Yamaji
%
% Permission is hereby granted, free of charge, to any person obtaining a copy of this software
% and associated documentation files (the "Software"), to deal in the Software without restriction,
@@ -22,85 +22,54 @@
% This package is located at : http://www.ctan.org/pkg/mcf2graph
% Suggestion or request mail to : mcf2graph@gmail.com
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-message "* This is mcf2graph ver 5.15 2024.12.01";
-tracingstats:=1; prologues:=3; warningcheck:=0;
+message "* This is mcf2graph ver 5.16 2025.01.05";
+tracingstats:=1; prologues:=3;
%-------------------------------------------------------------------------------------------------
-newinternal string EN_;
+newinternal string EN_,tempc,temps,blanks,line_s,atom_s,forbiddens,firstc,file_output;
+newinternal numeric nA,nB,nC,nD,nE,nL,nN,nP,nR,nS,nU,nX,nY,pX,pY,pcode_int;
numeric save_num[],pcode_x[][],pcode_y[][],param_e[][],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[],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;
+ lib_tag[][],lib_val[][],block_s[],mc,ex,ad,op,aux_delimiter,default_library,EN,FM,MW,MI,
+ CAT,JN,CAS,USE,EXA,EXB,file_input,default_temp_file,mpfont,atomfont,numberfont;
pair save_pair[],msize,mposition,fsize,fmargin,save_mposition;
%-------------------------------------------------------------------------------------------------
-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;
+fig_num:=str_cnt:=tbl_cnt:=mangle:=sw_frame:=sw_trimming:=sw_ext_all:=sw_omit:=sw_expand:=0;
+sw_comment:=sw_output:=sw_numbering:=tag_cnt:=rw_cnt:=pcode_all:=MW_n:=0;
%-------------------------------------------------------------------------------------------------
-aux_delimiter:=";"; blanks:= " "; forbiddens:=" &()[]{}^=;!'+,`~";
for s="No","EN","JN","MW","MI","FM","CAT","CAS","USE","EXA","EXB": tag[incr tag_cnt]:=s; endfor
-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;
-%-------------------------------------------------------------------------------------------------
-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 +++ = ++;
-%-------------------------------------------------------------------------------------------------
-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;
-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;
-vardef Incr suffix $ == $:=$+1; $ enddef;
+Fig:=1; Mcode:=2; Info:=4; Report:=8; MOL2k:=16; MOL3k:=32; Atom:=2; Bond:=4; All:=8;
+Group:=8; Mol:=16; Outside:=1; Inside:=2; Bothside:=Outside+Inside;
%=================================================================================================
default_library:="main_lib.mcf"; default_temp_file:="temp.mcf";
-mpfont:="uhvr8r"; atomfont:="draw"; defaultfont:=mpfont;
+mpfont:="uhvr8r"; atomfont:=numberfont:="draw"; defaultfont:=mpfont; let ef=elseif;
%--default ahangle=45---------------------------------------------------------------------
-if ahangle=1: outputformat:="png"; hppp:=vppp:=0.12; % png format(600dpi)
-ef ahangle=11: outputformat:="png"; hppp:=vppp:=0.06; % png format(1200dpi)
-ef ahangle=2: outputformat:="eps"; % eps format(.eps)
-ef ahangle=3: outputformat:="eps"; % eps format(.mps)
-ef ahangle=45: outputformat:="svg"; % svg format *default
+if ahangle=1: outputformat:="png"; hppp:=vppp:=0.12; % png format(600dpi)
+ef ahangle=11: outputformat:="png"; hppp:=vppp:=0.06; % png format(1200dpi)
+ef ahangle=2: outputformat:="eps"; % eps format(.eps)
+ef ahangle=3: outputformat:="eps"; % eps format(.mps)
+ef ahangle=45: outputformat:="svg"; % svg format *default
fi
%--default ahlength=4---------------------------------------------------------------------
-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
+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) ** max 500files
+ef ahlength=6: sw_output:=MOL3k; sw_expand:=1; % output MOL(V3000) ** max 500files
+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;
+ef bboxmargin=4: sw_output:=Fig+Report;
ext(defaultfont:=mpfont; defaultscale:=.3;
- label.rt(EN&" / "&MW&" / "&decimal(MW_n-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";
ef (outputformat="eps")and(ahangle=3): outputtemplate:="%j-%3c.mps";
-else: outputtemplate:="%j-%3c."&outputformat; fi
+else: outputtemplate:="%j-%3c."&outputformat;
+fi
%-----------------------------------------------------------------------------------------
message "* jobname="&jobname;
message "* numbersystem="&numbersystem;
@@ -108,19 +77,45 @@ 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;
%-------------------------------------------------------------------------------------------------
-ratio_chain_ring:=0.66; ratio_atom_bond:=0.36; ratio_thickness_bond:=0.015;
-ratio_thickness_char:=0.1; ratio_char_bond:=1.5; ratio_bondgap_bond:=0.15;
-ratio_hashgap_bond:=0.12; ratio_hash_black:=0.4; ratio_wedge_bond:=0.12; ratio_atomgap_atom:=0.04;
-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;
+ratio_chain_ring:=0.66; ratio_atom_bond:=0.36; ratio_thickness_bond:=0.012; ratio_char_atom:=0.12;
+ratio_bondgap_bond:=0.15; ratio_hashgap_bond:=0.12; ratio_hash_black:=0.4;
+ratio_wedge_bond:=0.12; ratio_atomgap_atom:=0.05; offset_thickness:=0.25; 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);
ahangle:=45; ahlength:=4; defaultsize:=8; defaultscale:=1; labeloffset:=3; ext_defaultline:=0.5;
lonepairdiam:=lonepairspace:=circlediam:=circlepen:=bboxmargin:=0; mc_length:=100;
outputformatoptions:="";
+%-------------------------------------------------------------------------------------------------
+let DIV= /; let MUL= *; let LT= <; let GT= >; let AND= &; let :: = : ; let == = =; let +++ = ++;
+let ISP=intersectionpoint; def ]]]=] ] ] enddef; vardef Incr suffix $ == $:=$+1; $ enddef;
+%-------------------------------------------------------------------------------------------------
+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 puts expr s= write s to file_output enddef;
+%-------------------------------------------------------------------------------------------------
+vardef frac primary n= n-floor n enddef;
+vardef iif(expr a,b,c)=if a: b else: c fi enddef;
+vardef sfrt(expr a,b,c)= a shifted ((b,0) rotated c) 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;
+%-------------------------------------------------------------------------------------------------
+aux_delimiter:=";"; blanks:= " "; forbiddens:=" &()[]{}^=;!'+,`~";
+for s="*/*","/*","*/","//","**","##","||":rw[incr rw_cnt]:=s; lenw[rw_cnt]:=length(s); endfor
+PRS:=ASCII("(");PRE:=ASCII(")");BRS:=ASCII("{");BRE:=ASCII("}");QES:=ASCII("?");DOL:=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(" ");
%=================================================================================================
pcode_emb_start:=1001; % 1001 => 1900 for embedded pcode (max 900)
pcode_emi_start:=1901; % 1901 => 2000 for embedded internal pcode (max 100)
@@ -128,25 +123,24 @@ pcode_usr_start:=2001; % 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,_chg_slen,_get_len,_ring_len,_tmp_len,_rot_ang,_adj_ang,
- _chg_env,_tmp_env,_set_colorA,_set_colorB,
- _group_si,_group_dm,_group_wf,_group_zf,_set_adr,_mk_bond,_set_atom,_arrange_ang,_chg_atom,
- _tmp_rot,_fuse,_fuse_ext,_size_atom,_numeric,_numeric_inv,_jump_at,_set_add,_chg_add,_nop,
+def_com(-4090)(_com,_jp_atom,_jp_absA,_jp_bond,_cyc,_cyc_sB,_cyc_eB,_set_line,_tmp_line,_tmp_rot,
+ _tmp_env,_tmp_len,_chg_len,_set_len,_get_len,_ring_len,_rot_ang,_adj_ang,_chg_env,_set_colorA,
+ _set_colorB,_group_si,_group_dm,_group_wf,_group_zf,_set_adr,_mk_bond,_set_atom,_arrange_ang,
+ _chg_atom,_fuse,_fuse_ext,_size_atom,_numeric,_numeric_inv,_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_);
%-------------------------------------------------------------------------------------------------
def parameter_list=
- sw_numbering,sw_expand,sw_output,sw_ext_all,sw_frame,sw_trimming,sw_abbreviate,ratio_atom_bond,
- ratio_thickness_bond,ratio_char_bond,ratio_chain_ring,ratio_bondgap_bond,ratio_hash_black,
- 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,
+ sw_numbering,sw_output,sw_ext_all,sw_frame,sw_trimming,sw_omit,ratio_atom_bond,
+ ratio_thickness_bond,ratio_chain_ring,ratio_bondgap_bond,ratio_hash_black,ratio_hashgap_bond,
+ ratio_wedge_bond,ratio_atomgap_atom,ratio_char_atom,offset_atom,offset_wedge,max_blength,
+ offset_hash_gap,offset_bond_gap,thickness_frame,offset_thickness,defaultsize,defaultscale,
labeloffset,mangle,blength,fsize,fmargin,msize,mposition,defaultfont,atomfont,dottedline_gap
enddef;
%-------------------------------------------------------------------------------------------------
-def init_par(text t)= nA:=nB:=nC:=0;
+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;
@@ -154,7 +148,8 @@ def init_par(text t)= nA:=nB:=nC:=0;
endfor
enddef;
%-------------------------------------------------------------------------------------------------
-def store_par(text t)= nA:=nB:=nC:=0;
+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
@@ -162,7 +157,8 @@ def store_par(text t)= nA:=nB:=nC:=0;
endfor
enddef;
%-------------------------------------------------------------------------------------------------
-def restore_par(text t)= nA:=nB:=nC:=0;
+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
@@ -172,117 +168,111 @@ enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def beginfigm=
begingroup
- 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;
+ save ','',`,``,//,@,#,#@,##,\,\\,\*,|=,|<,**,++,f_ext,blen,ext,add,ang_br,fw_n,bw_n,adr_n,
+ bond_cntA,unknown_cnt,unknown_s,warning_cnt,warning_s,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,no,mw,mi,fm,group_num,f_line,f_type,ay,bx,by,pcnt;
numeric hideH[],lineB[],sB[],eB[],angB[],angA[],lenB[],angX[],strA[],sumA[],bond_num[],
- wdM[],htM[],chargeA[],addA[],add_rot[];
+ wdM[],htM[],chargeA[],addA[],add_rot[];
pair posA[],posM[][];
- string mi,no,fm,mw,firstc,filter_s;
+ string unknown_s[],warning_s[],mi,no,fm,mw;
picture mol_pic[];
color color_list[];
%-----------------------------------------------------------------------------------------------
store_par(parameter_list);
- no:=mc:=ex:=ad:=op:=temps:=mw:=mi:=fm:=filter_s:="";
+ no:=mc:=ex:=ad:=op:=mw:=mi:=fm:="";
EN:=JN:=MW:=FM:=MI:=CAS:=CAT:=EXA:=EXB:=USE:="-";
- f_ext:=cntM:=mc_row:=ex_row:=ad_row:=op_row:=info_cnt:=err_cnt:=param_int:=0;
+ f_ext:=cntM:=mc_row:=ex_row:=ad_row:=op_row:=err_cnt:=param_int:=unknown_cnt:=warning_cnt:=0;
let ext=ext_to_fig; let add=add_to_molecule; let ++=add_to_molecule; let **=ext_to_fig;
- def '' = define_parts enddef; def '` = readm enddef; def \ = drawm enddef; def \\ = putm enddef; def \* = checkm enddef; def $ = getm enddef; def @ expr p = mposition:=p; enddef;
+ def '' = define_parts 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 s) = define_group_string(s)() enddef; def `` = define_group_string 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;
+ def |<(expr n) = max_blength:=n; enddef;
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):
- if EN<>"-": EN_:=forbidden_to_underbar(EN); fi
- beginfig(fig_num)
- %------------------------------------------------------------------------------------------
- if sw_ext_all=1: ext_to_fig(EXT_ALL); fi
- if sw_trimming>=1:
- nA:=nC:=4095; nB:=nD:=-4095;
- for i=1 upto cntM:
- if xpart(posM[1][i])<nA: nA:=xpart(posM[1][i]); fi
- if xpart(posM[2][i])>nB: nB:=xpart(posM[2][i]); fi
- if ypart(posM[1][i])<nC: nC:=ypart(posM[1][i]); fi
- if ypart(posM[2][i])>nD: nD:=ypart(posM[2][i]); fi
- endfor
- fig_wd:=nB-nA+2xpart(fmargin); fig_ht:=nD-nC+2ypart(fmargin); fsize:=(fig_wd,fig_ht);
+ if scan_bit(sw_output,Fig)::
+ if EN<>"-": EN_:=forbidden_to_underbar(EN); else: EN_:="no_name"; fi
+ beginfig(fig_num)
+ if sw_ext_all=1: ext_to_fig(EXT_ALL); fi
+ if sw_trimming>=1:
+ nA:=nC:=4095; nB:=nD:=-4095;
+ for i=1 upto cntM:
+ if xpart(posM[1][i])<nA: nA:=xpart(posM[1][i]); fi
+ if xpart(posM[2][i])>nB: nB:=xpart(posM[2][i]); fi
+ if ypart(posM[1][i])<nC: nC:=ypart(posM[1][i]); fi
+ if ypart(posM[2][i])>nD: nD:=ypart(posM[2][i]); fi
+ endfor
+ fig_wd:=nB-nA+2xpart(fmargin); fig_ht:=nD-nC+2ypart(fmargin); fsize:=(fig_wd,fig_ht);
+ for i=1 upto cntM:
+ posM[0][i]:=posM[0][i]+fmargin-(nA,nC); posM[1][i]:=posM[1][i]+fmargin-(nA,nC);
+ endfor
+ fi
+ if scan_bit(sw_frame,Outside): draw_frame((0,0),fsize,thickness_frame);
+ 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:
- posM[0][i]:=posM[0][i]+fmargin-(nA,nC); posM[1][i]:=posM[1][i]+fmargin-(nA,nC);
+ addto currentpicture also mol_pic[i] shifted posM[0][i]; mol_pic[i]:=nullpicture;
+ if scan_bit(sw_frame,Mol): ext(draw_frame(p[i],(w[i],h[i]),thickness_frame)) fi
endfor
- fi
- %----------------------------------------------------------------------------------------
- if scan_bit(sw_frame,Outside): draw_frame((0,0),fsize,thickness_frame);
- 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;
- if scan_bit(sw_frame,Mol): ext(draw_frame(p[i],(w[i],h[i]),thickness_frame)) fi
- endfor
- if f_ext=1: addto currentpicture also mol_pic[0]; mol_pic[0]:=nullpicture; fi
- %-----------------------------------------------------------------------------------------
- endfig;
- clearit;
- 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 f_ext=1: addto currentpicture also mol_pic[0]; mol_pic[0]:=nullpicture; fi
+ endfig;
+ clearit;
+ fi
ef scan_bit(sw_output,Fig):
- EN_:="no_figure";
+ if EN<>"-": EN_:=forbidden_to_underbar(EN); else: EN_:="no_name"; fi
beginfig(fig_num)
- defaultscale:=.6; draw_frame((0,0),fsize,thickness_frame) label("no figure",0.5fsize);
+ defaultscale:=.6; draw_frame((0,0),fsize,thickness_frame) label("no figure",0.5fsize);
endfig;
clearit;
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
+ 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
fi
- %---------------------------------------------------------------------------------------------
restore_par(parameter_list);
endgroup;
- message EN;
+ message "["&decimal(fig_num)&"]EN:"&EN; message "";
enddef;
%=================================================================================================
def readm(text s)=
- save fw_n,bw_n;
for list=s:
- fw_n:=scan_char(" ",list,1,1)-1; bw_n:=scan_char(" ",list,-1,1);
- mc_indent[incr mc_row]:=fw_n; mc[mc_row]:=substring(fw_n,bw_n) of list; mc:=mc&mc[mc_row];
+ fw_n:=scan_char(" ",list,1,1)-1;
+ bw_n:=scan_char(" ",list,-1,1);
+ mc_indent[incr mc_row]:=fw_n;
+ mc[mc_row]:=substring(fw_n,bw_n) of list;
+ mc:=mc&mc[mc_row];
endfor
enddef;
%=================================================================================================
def getm(expr a)=if string a: read_unit(get_adr("EN",a)) ef numeric a: read_unit(a) fi enddef;
%-------------------------------------------------------------------------------------------------
def read_unit(expr n)=
- save nF; nF:=0;
+ f_line:=0;
if (n>=1)and(n<=ucount):
for i=1 upto info[n]:
for j=1 upto tag_cnt: if lib_tag[n][i]=tag[j]: scantokens(tag[j]):=lib_val[n][i]; fi endfor
endfor
for i=1 upto unit_lines[n]:
- temps:=row[n][i]; firstc:=subc(1,temps); exitif firstc=";";
- if firstc=":": nF:=1; ef firstc="=": nF:=2; ef firstc="*": nF:=3; ef firstc="+": nF:=4;
+ line_s:=row[n][i]; firstc:=substring(0,1) of line_s; exitif firstc=";";
+ if firstc=":": f_line:=1; ef firstc="=": f_line:=2;
+ ef firstc="*": f_line:=3; ef firstc="+": f_line:=4;
ef firstc="%":
else:
- 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;
- ef nF=4: ad_indent[incr ad_row]:=fw_n; ad[ad_row]:=temps; ad:=ad&temps;
+ fw_n:=scan_char(" ",line_s,1,1)-1;
+ line_s:=substring(fw_n,length(line_s)) of line_s;
+ if f_line=1: mc_indent[incr mc_row]:=fw_n; mc[mc_row]:=line_s; mc:=mc&line_s;
+ ef f_line=2: op_indent[incr op_row]:=fw_n; op[op_row]:=line_s; op:=op&line_s;
+ ef f_line=3: ex_indent[incr ex_row]:=fw_n; ex[ex_row]:=line_s; ex:=ex&line_s;
+ ef f_line=4: ad_indent[incr ad_row]:=fw_n; ad[ad_row]:=line_s; ad:=ad&line_s;
fi
fi
endfor
@@ -290,7 +280,7 @@ def read_unit(expr n)=
enddef;
%=================================================================================================
vardef get_adr(expr t,v)=
- save adr_n; adr_n:=0;
+ adr_n:=0;
for n=1 upto ucount:
for i=1 upto info[n]:
for j=1 upto tag_cnt: if (lib_tag[n][i]=t)and(lib_val[n][i]=v): adr_n:=n; fi endfor
@@ -315,42 +305,47 @@ vardef pcode_extend(expr p,a,b,c,d)=
enddef;
def move_pos(expr n) =
<$0,angle(pcode_y[n][1],pcode_y[n][2])~0`length(pcode_y[n][1],pcode_y[n][2]),<$0 enddef;
+def message_unknown(expr n) =
+ unknown_s[incr unknown_cnt]:="*Unknown found in block("AND decimal(n)AND")";
+ message "["AND decimal(fig_num)AND"]"AND unknown_s[unknown_cnt];
+ message "";
+enddef;
%-------------------------------------------------------------------------------------------------
-vardef abs_adress primary n = if (n>=si)and(n<=bd_):: (_tmp_line,n) else:: n-4095 fi enddef;
+vardef abs_adress primary n =
+ if numeric n:: if (n>=si)and(n<=bd_):: (_tmp_line,n) else:: n-4095 fi else:: _nop fi enddef;
primarydef a from_until b = (_from,a),(_until,b) enddef;
-primarydef a op_quot b = if (known a)and(known b):: add_parts(a,b) else:: _nop fi enddef;
+primarydef a bop_qut b = if (known a)and(known b):: add_parts(a,b) else:: _nop fi enddef;
primarydef a fuse__ b = pcode_extend(_fuse_ext,a,b,2,0) enddef;
primarydef a fuse___ b = pcode_extend(_fuse_ext,a,b,3,0) enddef;
primarydef a fuse____ b = pcode_extend(_fuse_ext,a,b,4,0) 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 a)and(known b):: (_tmp_rot,b),a else:: _nop fi enddef;
-tertiarydef a op_til b = if (known a)and(known b):: (_tmp_line,b),a else:: _nop fi enddef;
-tertiarydef a op_lth b = if (known a)and(known b):: (_tmp_env,b),a else:: _nop fi enddef;
-tertiarydef a op_bqu b = if (known a)and(known b):: (_tmp_len,b),a else:: _nop fi enddef;
-def chg_length primary n = (_chg_slen,n) enddef;
-def rot_angle primary n = if known n:: (_rot_ang,n) else:: _nop fi enddef;
-def cyc_atom primary n = if known n:: (_cyc,n) else:: _nop fi enddef;
+tertiarydef a bop_equ b = if (known a)and(known b):: set_bond(a,b) else:: _nop fi enddef;
+tertiarydef a bop_col b = if (known a)and(known b):: set_atom(a,b) else:: _nop fi enddef;
+tertiarydef a bop_hat b = if (known a)and(numeric b):: (_tmp_rot,b),a else:: _nop fi enddef;
+tertiarydef a bop_til b = if (known a)and(numeric b):: (_tmp_line,b),a else:: _nop fi enddef;
+tertiarydef a bop_lth b = if (known a)and(numeric b):: (_tmp_env,b),a else:: _nop fi enddef;
+tertiarydef a bop_bqu b = if (known a)and(numeric b):: (_tmp_len,b),a else:: _nop fi enddef;
+def chg_length primary n = if numeric n:: (_set_len,n) else:: _nop fi enddef;
+def rot_angle primary n = if numeric n:: (_rot_ang,n) else:: _nop fi enddef;
+def cyc_atom primary n = if numeric n:: (_cyc,n) else:: _nop fi enddef;
def jump_atom secondary n = if n>=pcode_int_start:: move_pos(n) else::(_jp_atom,n) fi enddef;
-def jump_atom_abs secondary n = if n>=pcode_int_start::(_jp_atom,$1),move_pos(n)
- else::(_jp_atom,$n) fi enddef;
-def group_si secondary n = if known n:: (_group_si,n) else:: _nop fi enddef;
-def group_dm secondary n = if known n:: (_group_dm,n) else:: _nop fi enddef;
-def group_wf secondary n = if known n:: (_group_wf,n) else:: _nop fi enddef;
-def group_zf secondary n = if known n:: (_group_zf,n) else:: _nop fi enddef;
-def group_wv secondary n = if known n:: /n~wv else:: _nop fi enddef;
-def group_nb secondary n = if known n:: /n~nb else:: _nop fi enddef;
+def jump_atom_abs secondary n = if numeric n::
+ if n>=pcode_int_start::(_jp_atom,$1),move_pos(n) else::(_jp_atom,$n) fi else:: _nop fi enddef;
+def group_si secondary n = if numeric n:: (_group_si,n) else:: _nop fi enddef;
+def group_dm secondary n = if numeric n:: (_group_dm,n) else:: _nop fi enddef;
+def group_wf secondary n = if numeric n:: (_group_wf,n) else:: _nop fi enddef;
+def group_zf secondary n = if numeric n:: (_group_zf,n) else:: _nop fi enddef;
+def group_wv secondary n = if numeric n:: /n~wv else:: _nop fi enddef;
+def group_nb secondary n = if numeric n:: /n~nb else:: _nop fi enddef;
%=================================================================================================
def read_mcf(expr n)(text t)=
begingroup
if unknown inside_mc::
- save /,//,*,/*,*/,**,*/*,~,^,`,',<,>,:,=,\,\\,*\,\*,*\*,@,@$,$,&,&$,#,##,{,},|,||,_,
- --,---,----,CP,CA,CC,DL,FR,inside_mc;
- inside_mc:=1; | :=mark_adress; || :=reset_adress; ##:=reset_length; _:=NO_ATOM;
- \:=0; \\:=zero_dm; *\:=zero_wf; \*:=zero_zf; *\*:=zero_wv; let ' == op_quot; let = ==op_equ;
- let : ==op_col; let ^ ==op_hat; let ~ ==op_til; let > ==op_lth; let ` ==op_bqu;
- let -- == fuse__; let --- == fuse___; let ---- == fuse____; let } == );
- let @$ ==jump_atom_abs; let < ==rot_angle; let @ ==jump_atom; let & ==cyc_atom;
+ save /,//,*,/*,*/,**,*/*,~,^,`,',<,>,:,=,@,@$,$,&,&$,#,##,{,},|,||,--,---,----,
+ CP,CA,CC,DL,FR,inside_mc;
+ inside_mc:=1; | :=mark_adress; || :=reset_adress; ##:=reset_length;
+ let ' == bop_qut; let = ==bop_equ; let : ==bop_col; let ^ ==bop_hat; let ~ ==bop_til;
+ let > ==bop_lth; let ` ==bop_bqu; let -- == fuse__; let --- == fuse___; let ---- == fuse____;
+ 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; let CP == pcode_add; let CA == pcode_add_adr;
let FR == fuse_ring_bonds; def DL(expr p)==CA(_set_line,dl,p) enddef;
@@ -359,18 +354,19 @@ def read_mcf(expr n)(text t)=
def * primary p == (_numeric_inv,p) enddef;
fi
%----------------------------------------------------------------------------------------------
- pcode_cnt[n]:=0;
+ pcode_cnt[n]:=block_cnt:=0;
for list==t::
+ block_cnt:=block_cnt+1;
if known list::
if pair list::
pcode_x[n][Incr pcode_cnt[n]]:=xpart(list); pcode_y[n][pcode_cnt[n]]:=ypart(list);
ef numeric list::
- if list==_nop:: message "unknown command in "AND decimal(n);
+ if list==_nop:: message_unknown(block_cnt);
ef list>=pcode_emb_start:: expand_pcode(n,list);
else:: pcode_x[n][Incr pcode_cnt[n]]:=_mk_bond; pcode_y[n][pcode_cnt[n]]:=list;
fi
fi
- else:: message "unknown command in "AND decimal(n);
+ else:: message_unknown(block_cnt);
fi
endfor
endgroup
@@ -389,13 +385,13 @@ def expand_pcode(expr n,a)=
enddef;
%-------------------------------------------------------------------------------------------------
vardef read_adress(text t)=
- save :,',pcnt,start_num;
+ save :,',start_num;
let ' == , ; let : == from_until;
pcode_int:=pcode_int+1; pcnt:=0;
for list==t::
if known list::
if numeric list::
- if list==_nop:: message "unknown command in "AND decimal(pcode_int);
+ if list==_nop:: message_unknown(block_cnt);
else:: pcode_x[pcode_int][Incr pcnt]:=_numeric; pcode_y[pcode_int][pcnt]:=list;
fi
ef pair list::
@@ -407,7 +403,7 @@ vardef read_adress(text t)=
else:: pcode_x[pcode_int][Incr pcnt]:=xpart(list); pcode_y[pcode_int][pcnt]:=ypart(list);
fi
fi
- else:: message "unknown command in "AND decimal(pcode_int);
+ else:: message_unknown(block_cnt);
fi
endfor
pcode_cnt[pcode_int]:=pcnt; pcode_int
@@ -417,13 +413,13 @@ vardef add_parts(expr a,b)=
if (pair a)and(pair b)::
pcode_x[Incr pcode_int][1]:=xpart a; pcode_y[pcode_int][1]:=ypart a;
pcode_x[pcode_int][2]:=xpart b; pcode_y[pcode_int][2]:=ypart b; pcode_cnt[pcode_int]:=2;
- elseif pair a::
+ ef (pair a)and(numeric b)::
pcode_x[Incr pcode_int][1]:=xpart a; pcode_y[pcode_int][1]:=ypart a;
if b>=pcode_emb_start:: pcode_x[pcode_int][2]:=b;
else:: pcode_x[pcode_int][2]:=_numeric; pcode_y[pcode_int][2]:=b;
fi
pcode_cnt[pcode_int]:=2;
- elseif pair b::
+ ef (numeric a)and(pair b)::
if a>=pcode_int_start::
pcode_x[a][Incr pcode_cnt[a]]:=xpart b; pcode_y[a][pcode_cnt[a]]:=ypart b;
elseif a>=pcode_emb_start::
@@ -433,10 +429,10 @@ vardef add_parts(expr a,b)=
pcode_x[Incr pcode_int][1]:=_numeric; pcode_y[pcode_int][1]:=a;
pcode_x[pcode_int][2]:=xpart b; pcode_y[pcode_int][2]:=ypart b; pcode_cnt[pcode_int]:=2;
fi
- elseif (a LT pcode_emb_start)and(b LT pcode_emb_start)::
+ ef (a LT pcode_emb_start)and(b LT pcode_emb_start)::
pcode_x[Incr pcode_int][1]:=_numeric; pcode_y[pcode_int][1]:=a;
pcode_x[pcode_int][2]:=_numeric; pcode_y[pcode_int][2]:=b; pcode_cnt[pcode_int]:=2;
- elseif (a>=pcode_int_start)and(b LT pcode_int_start)::
+ ef (a>=pcode_int_start)and(b LT pcode_int_start)::
if b>=pcode_emb_start:: pcode_x[a][Incr pcode_cnt[a]]:=b;
else:: pcode_x[a][Incr pcode_cnt[a]]:=_numeric; pcode_y[a][pcode_cnt[a]]:=b;
fi
@@ -446,124 +442,126 @@ vardef add_parts(expr a,b)=
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def fuse_ring(expr a,b) =
- CP(_jp_bond,a) CP(_rot_ang,180) CP(_get_len,a) CC(_len_s) CP(_chg_len,_ring_len)
+ CP(_jp_bond,a) CP(_rot_ang,180) CP(_get_len,a) CP(_set_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) 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
+ CP(_jp_bond,s) CP(_rot_ang,180)
+ if b==6:: CP(_set_len,1) for i==1 upto c-1:: CB(60) endfor
+ ef b==5:: if c==2:: CP(_set_len,1.25) CB(80) ef c==3:: CP(_set_len,1.1) CB(78) CB(72) fi
+ ef b==4:: CP(_set_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) 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
- fi
+ CP(_jp_bond,a) CP(_rot_ang,180) CP(_set_len,c)
+ if b==5:: CB(72-((10c-9) MUL 1.5)) CB(63+10c) CB(63+10c)
+ ef b==6:: CB(68-10c) for i==1 upto 3:: CB(60+(5c-4)) 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) =
- save pY;
- if known b:: pcode_cnt[Incr pcode_int]:=0;
- if numeric b::
- if (b>=si)and(b<=bd_)::
+vardef set_bond(expr a,b) =
+ pcode_cnt[Incr pcode_int]:=0;
+ if numeric b::
+ if (b>=si)and(b<=bd_)::
+ if a>=pcode_int_start::
+ for i==1 upto pcode_cnt[a]::
+ if pcode_x[a][i]==_numeric:: CA(_set_line,b,pcode_y[a][i])
+ elseif pcode_x[a][i]==_numeric_inv::
+ if b==dl:: CA(_set_line,dr,pcode_y[a][i])
+ ef b==dr:: CA(_set_line,dl,pcode_y[a][i]) fi
+ fi
+ endfor
+ else:: CP(_set_adr,a) CP(_set_line,b)
+ fi
+ ef (b>=?3)and(b<=Ph2)or(b>=pcode_int_start)::
+ if numeric a::
if a>=pcode_int_start::
for i==1 upto pcode_cnt[a]::
- if pcode_x[a][i]==_numeric:: CA(_set_line,b,pcode_y[a][i])
- elseif pcode_x[a][i]==_numeric_inv::
- if b==dl:: CA(_set_line,dr,pcode_y[a][i])
- ef b==dr:: CA(_set_line,dl,pcode_y[a][i]) fi
+ ay:=pcode_y[a][i];
+ if pcode_x[a][i]==_numeric::
+ if b==Ph1:: fuse_ring(ay,6) DL(-2) DL(-4)
+ ef b==Ph2:: fuse_ring(ay,6) DL(-1) DL(-3) DL(-5)
+ else:: fuse_ring(ay,b-?3+3) fi
+ ef pcode_x[a][i]==_fuse_ext::
+ if b==?6:: FR(param_e[ay][1],param_e[ay][2],6,6-param_e[ay][3])
+ ef b==?5:: FR(param_e[ay][1],param_e[ay][2],5,5-param_e[ay][3])
+ ef b==?4:: FR(param_e[ay][1],param_e[ay][2],4,2) fi
fi
endfor
- else:: CP(_set_adr,a) CP(_set_line,b)
- fi
- elseif (b>=?3)and(b<=?6[15])::
- if numeric a::
- if a>=pcode_int_start::
- for i==1 upto pcode_cnt[a]::
- pY:=pcode_y[a][i];
- if pcode_x[a][i]==_numeric::
- if b==Ph1:: fuse_ring(pY,6) DL(-2) DL(-4)
- ef b==Ph2:: fuse_ring(pY,6) DL(-1) DL(-3) DL(-5)
- ef (b>=?5[11])and(b<=?6[15]):: fuse_ring_size(a,pcode_x[b][1],pcode_y[b][1])
- else:: fuse_ring(pY,b-?3+3)
- fi
- ef pcode_x[a][i]==_fuse_ext::
- if b==?6:: FR(param_e[pY][1],param_e[pY][2],6,6-param_e[pY][3])
- ef b==?5:: FR(param_e[pY][1],param_e[pY][2],5,5-param_e[pY][3])
- ef b==?4:: FR(param_e[pY][1],param_e[pY][2],4,2)
- fi
- fi
- endfor
- else::
- 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<=?6[15]):: fuse_ring_size(a,pcode_x[b][1],pcode_y[b][1])
- else:: fuse_ring(a,b-?3+3) fi
- fi
- ef pair a::
- if b==?6:: FR(param_e[ypart a][1],param_e[ypart a][2],6,6-param_e[ypart a][3])
- ef b==?5:: FR(param_e[ypart a][1],param_e[ypart a][2],5,5-param_e[ypart a][3])
- ef b==?4:: FR(xpart a,ypart a,4,2)
+ else::
+ 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>=pcode_int_start::
+ if (pcode_x[b][1]==_set_len)and(pcode_x[b][2]>=?5)and(pcode_x[b][2]<=?6)::
+ fuse_ring_size(a,pcode_x[b][2]-?3+3,pcode_y[b][1]) fi
+ else:: fuse_ring(a,b-?3+3)
fi
fi
+ ef pair a::
+ if b==?6:: FR(param_e[ypart a][1],param_e[ypart a][2],6,6-param_e[ypart a][3])
+ ef b==?5:: FR(param_e[ypart a][1],param_e[ypart a][2],5,5-param_e[ypart a][3])
+ ef b==?4:: FR(xpart a,ypart a,4,2) fi
fi
- elseif color b:: cntC:=cntC+1; color_list[cntC]:=b; CA(_set_colorB,cntC,a) fi
- pcode_int
- fi
+ else:: message_unknown(block_cnt);
+ fi
+ elseif color b:: cntC:=cntC+1; color_list[cntC]:=b; CA(_set_colorB,cntC,a) fi
+ pcode_int
enddef;
%-------------------------------------------------------------------------------------------------
-vardef change_atom(expr a,b)=
- if known b:: pcode_cnt[Incr pcode_int]:=pcnt:=0;
- if numeric b::
- if (b GT pcode_emb_start)and(b<=pcode_atm_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==?O:: CC(_group_s) CA(_group_dm,O,a) CC(_group_e)
- ef b==?NH:: CC(_group_s) CA(_group_dm,NH,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::
- CC(_group_s)
- if a>=pcode_emb_start::
- for i==1 upto pcode_cnt[a]::
- if pcode_x[a][i]==_numeric:: CA(xpart(b),ypart(b),pcode_y[a][i])
- ef pcode_x[a][i]==_numeric_inv::
- if xpart(b)==_group_wf:: CA(_group_zf,ypart(b),pcode_y[a][i])
- ef xpart(b)==_group_zf:: CA(_group_wf,ypart(b),pcode_y[a][i]) fi
- else:: CP(pcode_x[a][i],pcode_y[a][i])
- fi
- endfor
- else:: CA(xpart(b),ypart(b),a) fi
- CC(_group_e)
- ef color b:: cntC:=cntC+1; color_list[cntC]:=b; CA(_set_colorA,cntC,a)
+vardef set_atom(expr a,b)=
+ pcode_cnt[Incr pcode_int]:=pcnt:=f_type:=0;
+ if numeric b:: if (b>=?)and(b<=?dm):: bx:=pcode_x[b][1]; by:=pcode_y[b][1]; f_type:=1; fi
+ ef pair b:: bx:=xpart(b); by:=ypart(b); f_type:=1;
+ ef color b:: f_type:=2;
+ fi
+ if f_type==0::
+ if (b GT pcode_emb_start)and(b<=pcode_atm_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,NO_ATOM,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==?O:: CC(_group_s) CA(_group_dm,O,a) CC(_group_e)
+ ef b==?NH:: CC(_group_s) CA(_group_dm,NH,a) CC(_group_e)
+ ef b==??:: CP(_tmp_rot, 35) CC(_group_s) CA(_group_si,NO_ATOM,a) CC(_group_e)
+ CP(_tmp_rot,-35) CC(_group_s) CA(_group_si,NO_ATOM,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)
+ ef b==_nop:: message_unknown(block_cnt);
fi
- pcode_cnt[pcode_int]:=pcode_cnt[pcode_int]; pcode_int
+ ef f_type==1::
+ CC(_group_s)
+ if a>=pcode_emb_start::
+ for i==1 upto pcode_cnt[a]::
+ if pcode_x[a][i]==_numeric:: CA(bx,by,pcode_y[a][i])
+ ef pcode_x[a][i]==_numeric_inv::
+ if bx==_group_wf:: CA(_group_zf,by,pcode_y[a][i])
+ ef bx==_group_zf:: CA(_group_wf,by,pcode_y[a][i])
+ fi
+ else:: CP(pcode_x[a][i],pcode_y[a][i])
+ fi
+ endfor
+ else:: CA(bx,by,a) fi
+ CC(_group_e)
+ ef f_type==2:: cntC:=cntC+1; color_list[cntC]:=b; CA(_set_colorA,cntC,a)
fi
+ pcode_cnt[pcode_int]:=pcode_cnt[pcode_int]; pcode_int
enddef;
%-------------------------------------------------------------------------------------------------
-def pcode_add(expr c,p)= pcode_x[pcode_int][Incr pcode_cnt[pcode_int]]:=c;
- pcode_y[pcode_int][pcode_cnt[pcode_int]]:=p;
+def pcode_add(expr x,y)= pcode_x[pcode_int][Incr pcode_cnt[pcode_int]]:=x;
+ pcode_y[pcode_int][pcode_cnt[pcode_int]]:=y;
enddef;
-def pcode_add_adr(expr c,p,a)=
+%-------------------------------------------------------------------------------------------------
+def pcode_add_adr(expr x,y,a)=
if a>=pcode_emb_start::
for i==1 upto pcode_cnt[a]::
- if pcode_x[a][i]==_numeric:: pcode_add(_set_adr,pcode_y[a][i]) pcode_add(c,p)
+ if pcode_x[a][i]==_numeric:: pcode_add(_set_adr,pcode_y[a][i]) pcode_add(x,y)
else:: pcode_add(pcode_x[a][i],pcode_y[a][i])
fi
endfor
- else:: pcode_add(_set_adr,a) pcode_add(c,p)
+ else:: pcode_add(_set_adr,a) pcode_add(x,y)
fi
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -625,9 +623,9 @@ enddef;
%=================================================================================================
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,
- group_num,markA,markB,saveA,saveB,bondL,lenT,lineT,angT,rotT,envT,envB,rate_cr,posBs,posBe,
+ save f_bra,temp_strA,len_e_T,len_ee_T,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;
numeric group_com[][],group_par[][],group_cnt[],colorA[],colorB[];
@@ -641,7 +639,8 @@ def drawm(text t)=
%===============================================================================================
read_mcf(0)(t,(_com,_term));
proc_bond_atom(0)(1);
- if (group_num>0)and(not scan_bit(sw_abbreviate,Group)): expand_group(1); fi
+ backboneA:=cntA; backboneB:=cntB;
+ if (group_num>0)and(not scan_bit(sw_omit,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;
@@ -654,10 +653,13 @@ def drawm(text t)=
proc_skeleton(0); proc_scaling;
if (mol_ht/mol_wd)>(m_ht/m_wd):
if ypart(msize)>1: factor:=ypart(msize)/mol_ht;
- else: factor:=((fig_ht-2ypart(fmargin))*ypart(msize))/mol_ht; fi
+ else: factor:=((fig_ht-2ypart(fmargin))*ypart(msize))/mol_ht;
+ fi
else:
if xpart(msize)>1: factor:=xpart(msize)/mol_wd;
- else: factor:=((fig_wd-2xpart(fmargin))*xpart(msize))/mol_wd; fi fi
+ else: factor:=((fig_wd-2xpart(fmargin))*xpart(msize))/mol_wd;
+ fi
+ fi
exitif (factor>=1-eps)and(factor<=1+eps); blen:=blen*factor; proc_size_setup;
endfor
if blen>max_blength: blen:=max_blength; proc_size_setup; proc_skeleton(0); proc_scaling; fi
@@ -685,27 +687,25 @@ def drawm(text t)=
for i=1 upto cntB: if lineB[i]>=si_: draw_bond(i); fi endfor
%-atom numbering------------------------------------------------------------------------------
if scan_bit(sw_numbering,Atom):
- for i=1 upto cntA:
- if (i>=numbering_start)and(i<=numbering_end):
- defaultscale:=.18blen/defaultsize; nH:=1.2defaultsize*defaultscale;
- if i<=9: nW:=nH; ef i<=99: nW:=1.3nH; else: nW:=1.9nH; fi
- erase fill unitsquare xscaled nW yscaled nH shifted (posA[i]-(nW/2,nH/2));
- draw unitsquare xscaled nW yscaled nH shifted (posA[i]-(nW/2,nH/2)) wpcs 0.1;
- label(decimal(i),posA[i]);
- fi
+ if scan_bit(sw_numbering,All): numbering_end:=cntA; else: numbering_end:=backboneA; fi
+ for i=1 upto numbering_end:
+ defaultscale:=.2blen/defaultsize; nH:=1.2defaultsize*defaultscale;
+ if i<=9: nW:=nH; ef i<=99: nW:=1.3nH; else: nW:=1.9nH; fi
+ erase fill fullcircle xscaled 1.1nW yscaled 1.1nH shifted posA[i] wpcs 0.1;
+ draw fullcircle xscaled 1.1nW yscaled 1.1nH shifted posA[i] wpcs 0.1;
+ if numberfont="draw": draw_number(i,posA[i]); else: label(decimal(i),posA[i]); fi
endfor
fi
%-bond numbering------------------------------------------------------------------------------
if scan_bit(sw_numbering,Bond):
- for i=1 upto cntB:
- if (i>=numbering_start)and(i<=numbering_end):
- defaultscale:=.18blen/defaultsize; nH:=1.2defaultsize*defaultscale;
- if i<=9: nW:=nH; ef i<=99: nW:=1.3nH; else: nW:=1.9nH; fi
- nH:=defaultsize*defaultscale; tpos:=.5[posA[sB[i]],posA[eB[i]]];
- 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
+ if scan_bit(sw_numbering,All): numbering_end:=cntB; else: numbering_end:=backboneB; fi
+ for i=1 upto numbering_end:
+ defaultscale:=.18blen/defaultsize; nH:=1.2defaultsize*defaultscale;
+ if i<=9: nW:=nH; ef i<=99: nW:=1.3nH; else: nW:=1.9nH; fi
+ nH:=defaultsize*defaultscale; tpos:=.5[posA[sB[i]],posA[eB[i]]];
+ erase fill unitsquare xscaled nW yscaled 1.05nH shifted (tpos-(nW/2,1.05nH/2));
+ draw unitsquare xscaled nW yscaled 1.05nH shifted (tpos-(nW/2,1.05nH/2)) wpcs 0.1;
+ if numberfont="draw": draw_number(i,tpos); else: label(decimal(i),tpos); fi
endfor
fi
%---------------------------------------------------------------------------------------------
@@ -718,7 +718,7 @@ def drawm(text t)=
mol_pic[cntM]:=currentpicture;
clearit;
fi
- if sw_output>=Calc: proc_calc(0); fi
+ proc_calc(0);
endgroup;
enddef;
%-------------------------------------------------------------------------------------------------
@@ -757,7 +757,7 @@ def proc_scaling=
if strA[i]<>0:
nU:=nD:=nP:=nL:=nR:=0;
for j=1 upto length(str_tbl[strA[i]]):
- tempc:=subc(j,str_tbl[strA[i]]);
+ tempc:=substring(j-1,j) of 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
@@ -776,8 +776,7 @@ enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def proc_bond_atom(expr a)(expr n)=
f_bra:=f_term:=rotT:=f_lineT:=f_rotT:=f_lenT:=f_envT:=envT:=envB:=temp_strA:=f_at:=0;
- bondL:=rate_cr; lenT:=rate_cr; sB[0]:=0; eB[0]:=1; lineT:=si;
- addAT:=markA:=markB:=saveA:=saveB:=0;
+ addAT:=markA:=markB:=saveA:=saveB:=sB[0]:=0; bondL:=rate_cr; lenT:=rate_cr; eB[0]:=1; lineT:=si;
%-----------------------------------------------------------------------------------------------
for i=n upto pcode_cnt[a]: pX:=pcode_x[a][i]; pY:=pcode_y[a][i];
if pX=_mk_bond: if (pY=0)and(rotT<>0): rotT:=0; fi add_atom(0);
@@ -786,12 +785,13 @@ def proc_bond_atom(expr a)(expr n)=
ef pY=_rest: markA:=saveA; markB:=saveB;
ef pY=_moff: markA:=markB:=0;
ef pY=_term: termA;
- ef pY=_len_s: temp_lenE:=bondL; ef pY=_len_e: bondL:=temp_lenE;
- ef pY=_len_ss: temp_lenF:=bondL; ef pY=_len_ee: bondL:=temp_lenF;
+ ef pY=_len_s: len_e_T:=bondL; ef pY=_len_e: bondL:=len_e_T;
+ ef pY=_len_ss: len_ee_T:=bondL; ef pY=_len_ee: bondL:=len_ee_T;
ef pY=_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 pY=_group_e: f_at:=0; f_lineT:=f_rotT:=f_lenT:=f_envT:=rotT:=envT:=0;
- lineT:=si; lenT:=rate_cr; fi
+ ef pY=_group_e: f_at:=f_lineT:=f_rotT:=f_lenT:=f_envT:=rotT:=envT:=0;
+ lineT:=si; lenT:=rate_cr;
+ fi
ef pX=_set_atom: temp_strA:=pY;
ef pX=_group_si: add_group(pY);
ef pX=_group_dm: lineT:=dm; add_group(pY);
@@ -802,11 +802,13 @@ def proc_bond_atom(expr a)(expr n)=
ef pX=_jp_absA: sB[cntB+1]:=pY; f_bra:=1; temp_cntB:=cntB;
ef pX=_chg_atom: strA[getA(adrT)]:=pcode_y[pY][1];
ef pX=_chg_len: if pY=_ring_len: bondL:=ringL; else: bondL:=pY; fi
- ef pX=_chg_slen: temp_lenE:=bondL; if pY=_ring_len: bondL:=ringL; else: bondL:=pY; fi
+ ef pX=_set_len: len_e_T:=bondL; if pY=_ring_len: bondL:=ringL; else: bondL:=pY; fi
ef pX=_get_len: if pY=_tmp_len: if bondL=rate_cr: bondL:=lenT; fi
ef pY=_ring_len:
- if lenT<>rate_cr: bondL:=lenT; else: if bondL<0: bondL:=1; fi fi
- else: ringL:=lenB[getB(pY)]; fi
+ if lenT<>rate_cr: bondL:=lenT; else: if bondL<0: bondL:=1; fi
+ fi
+ else: ringL:=lenB[getB(pY)];
+ fi
ef pX=_tmp_len: lenT:=pY;
ef pX=_set_line: lineB[getB(adrT)]:=pY;
ef pX=_tmp_line: lineT:=pY;
@@ -826,8 +828,8 @@ def proc_bond_atom(expr a)(expr n)=
enddef;
%-------------------------------------------------------------------------------------------------
def add_group(expr n)=
- 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)
+ if f_at=1: nA:=getA(adrT); check_adrA(nA); else: nA:=cntA+1; fi
+ group_cnt[incr group_num]:=0; store_group(_jp_absA,nA)
store_group(_com,_mark)
store_group(_com,_len_s)
if lineT<>nb: store_group(_tmp_line,lineT) fi
@@ -858,7 +860,8 @@ def add_atom(expr n)=
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
+ else: f_bra:=0;
+ fi
if n=0: eB[cntB]:=cntA+1; f_term:=0; else: eB[cntB]:=n; f_term:=1; fi
enddef;
%-------------------------------------------------------------------------------------------------
@@ -867,9 +870,8 @@ def check_adrA(expr n)=
def check_adrB(expr n)= if (n>cntB)or(n<=0): errmessage("cntB=[ "&decimal(n)&" ]"); fi enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def proc_skeleton(expr n)=
- markA:=markB:=cntA:=cntB:=f_bra:=rotT:=f_term:=0;
- 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);
+ markA:=markB:=cntA:=cntB:=f_bra:=rotT:=f_term:=envT:=envB:=f_lineT:=f_rotT:=f_lenT:=f_envT:=0;
+ angA[0]:=angB[0]:=angX[0]:=0; lineT:=si; angT:=mangle; posA[0]:=posBs:=posBe:=(0,0);
%-----------------------------------------------------------------------------------------------
for i=1 upto pcode_cnt[n]: pX:=pcode_x[n][i]; pY:=pcode_y[n][i];
if pX=_mk_bond: if (pY=0)and(rotT<>0):pY:=rotT; rotT:=0; fi add_bond(pY,1);
@@ -903,23 +905,27 @@ def add_bond(expr n,f)=
cntB:=cntB+1;
if nA>-3700: angB[cntB]:=angT:=(angT+nA) mod 360; else: angB[cntB]:=angT:=nA+4095; fi
if f=1:
- if lenB[cntB]=_size_atom: posBe:=sfrt(posBs,atom_wd,angT);
+ if lenB[cntB]=_size_atom: posBe:=sfrt(posBs,1.12atom_wd,angT);
else:
nA:=lenB[cntB]; if nA<0: nB:=glu_atom(adrT)+glu_atom(cntA+1); nA:=abs(nA); else: nB:=0; fi
posBe:=sfrt(posBs,nA*blen+nB,angT); fi
posA[cntA+1]:=posBe; f_term:=0;
- else: f_term:=1; fi
+ else: f_term:=1;
+ fi
posBs:=posBe;
enddef;
%-------------------------------------------------------------------------------------------------
vardef arrange_ang(expr n)=
- if cntB=0: angT:=(angT-180) mod 360; 180
- else: if envB>=pcode_emb_start: pcode_y[envB][cntB-temp_cntB]
- 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
+ if f_bra=1: 0
+ else:
+ if cntB=0: angT:=(angT-180) mod 360; 180
+ else: if envB>=pcode_emb_start: pcode_y[envB][cntB-temp_cntB]
+ 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
fi
enddef;
%-------------------------------------------------------------------------------------------------
@@ -941,19 +947,25 @@ 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
+ save squ_a,hwd,glu_n;
+ if strA[n]<>0:
+ squ_a:=angT mod 90; hwd:=0.5atom_wd; glu_n:=(iif(squ_a<45,sind squ_a,cosd squ_a)*hwd)+++hwd;
+ glu_n
+ else: 0
+ fi
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def draw_atom(expr n)=
if atomfont<>"draw": defaultfont:=atomfont; defaultsize:=atom_wd; fi
- temps:=str_tbl[strA[n]]; slen:=length(temps); nC:=nS:=0; raise_pos:=(0,0); tpos:=posA[n];
+ atom_s:=str_tbl[strA[n]]; slen:=length(atom_s); nC:=nS:=0; raise_pos:=(0,0); tpos:=posA[n];
if (angX[n]<=90)or(angX[n]>=270): sdir:=1; else: sdir:=-1; fi
for i=1 upto slen:
- if nC=0: tempc:=subc(i,temps);
+ if nC=0: tempc:=substring(i-1,i) of atom_s;
if (sdir=-1)and(tempc="{"):
- nD:=i; nC:=0; for j=nD upto slen: nC:=nC+1; exitif subc(j+1,temps)="}"; endfor
+ nD:=i; nC:=0; for j=nD upto slen: nC:=nC+1; exitif substring(j,j+1) of atom_s="}"; endfor
fi
- else: nC:=nC-1; tempc:=subc(nD+nC,temps); fi
+ else: nC:=nC-1; tempc:=substring(nD+nC-1,nD+nC) of atom_s;
+ 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));
ef (tempc<>"{")and(tempc<>"}"):
@@ -973,6 +985,18 @@ def draw_atom(expr n)=
fi
if scan_bit(sw_frame,Atom): draw frameA[n] wpcs thickness_frame; fi
enddef;
+%-------------------------------------------------------------------------------------------------
+def draw_number(expr n,p)=
+ begingroup
+ save atom_wd,bond_pen_wd,slen,spos;
+ pair spos;
+ atom_wd:=.18blen; bond_pen_wd:=.012blen; temps:=decimal(n); slen:=length(temps); spos:=p;
+ for i=1 upto slen:
+ if i=1: spos:=spos-(slen*.35atom_wd-.35atom_wd,0); else: spos:=spos+(0.73atom_wd,0); fi
+ draw_char(substring(i-1,i) of temps,spos);
+ endfor
+ endgroup
+enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def draw_bond(expr n)=
nL:=lineB[n]; angL:=angB[n]; nS:=sB[n]; nE:=eB[n]; f_col:=0;
@@ -982,12 +1006,13 @@ def draw_bond(expr n)=
Ls:=posA[nS]; Le:=posA[nE]; pA:=(.1,.9);
ef strA[nS]=0: Ls:=posA[nS]; Le:=zL ISP frameA[nE]; pA:=(.15,1);
ef strA[nE]=0: Ls:=zL ISP frameA[nS]; Le:=posA[nE]; pA:=(0,.85);
- else: Ls:=zL ISP frameA[nS]; Le:=zL ISP frameA[nE]; pA:=(0,1); fi
+ else: Ls:=zL ISP frameA[nS]; Le:=zL ISP frameA[nE]; pA:=(0,1);
+ fi
zA:=Ls--Le; lenL:=length(Le-Ls);
%-----------------------------------------------------------------------------------------------
if known tcol: if tcol<>0: drawoptions(withcolor color_list[tcol]); f_col:=1;fi fi
pickup pencircle scaled bond_pen_wd;
- if (nL=si)or(scan_bit(sw_abbreviate,Bond)): draw zA;
+ if (nL=si)or(scan_bit(sw_omit,Bond)): draw zA;
ef nL=dl: draw zA; draw sfrt(subpath pA of zA,bondgap,ap);
ef nL=dr: draw zA; draw sfrt(subpath pA of zA,bondgap,am);
ef nL=dm: draw sfrt(zA,bondgap/1.75,ap); draw sfrt(zA,bondgap/1.75,am);
@@ -1042,25 +1067,30 @@ def draw_bond(expr n)=
ef nL=arc_ltr: draw posA[nS]+(0,iif(strA[nS]=0,0,0.6aw))--posA[nS]+(0,.8aw)
..0.5[posA[nS],posA[nE]]+(0,1.7aw)..posA[nE]+(0,.8aw)
--posA[nE]+(0,iif(strA[nE]=0,0,.6aw));
- %----------------------------------------------------------------------------------------------
fi
if f_col=1: drawoptions(); fi
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
+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;
%------------------------------------------------------------------------------------------------
-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;
+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;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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
+ for j=1 upto length(s):
+ nA:=ASCII(substring(j-1,j) of s); tbl_char_wd[nA]:=w; tbl_char_ht[nA]:=h;
+ endfor
enddef;
%-------------------------------------------------------------------------------------------------
char_size_set( 1, 1)("CGHMNOQW");
@@ -1099,7 +1129,7 @@ def draw_char(expr s,p)=
aW:=atom_wd*tbl_char_wd[ASCII(s)]*(1-2ratio_atomgap_atom);
aH:=atom_wd*tbl_char_ht[ASCII(s)]*(1-2ratio_atomgap_atom);
cpos:=p-(aW/2,atom_wd/2*(1-2ratio_atomgap_atom));
- fP:=bond_pen_wd*ratio_char_bond;
+ fP:=atom_wd*ratio_char_atom;
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;
@@ -1108,12 +1138,13 @@ def draw_char(expr s,p)=
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="F": dwh Z_q--Z_u; dwh (.1hP,.48aH)--(fW-hP,.48aH); dwv 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;
- ef s="3": cdw sbp(0,.75)circ_Oh; cdw sbp(.25,.98)circ_Oh shifted (0,hH-hP); dwh (.3aW,hH)--Z_y;
+ ef s="3": cdw sbp(0,.75)circ_Oh; cdw sbp(.25,.95)circ_Oh shifted (0,hH-hP);
+ dwh (.3aW,hH)--(.7aW,hH);
ef s="4": dwh Z_j--Z_k; dwv Z_l--(0.75aW,aH)--(1.2hP,qH+hP); dwv (.75aW+qP,aH)--(1.7hP,qH+hP);
ef s="-": dwh Z_m--Z_o;
ef s="+": dwv Z_x--Z_s; dwh Z_m--Z_o;
@@ -1165,8 +1196,8 @@ def draw_char(expr s,p)=
ef s="z": dwh Z_q--Z_u; dwvs(1.4)(1.4hP,fP)--(aW-1.4hP,aH-fP); dwh Z_a--Z_d;
ef s="0": dw Z_m...Z_s...Z_o...Z_x...cycle;
ef s="1": dwv Z_g--(hW,aH-.3hP)--(hW-fP,aH-fP)--(hW-fP,aH-1.5fP);
- ef s="5": dwh Z_q--Z_u; dwv Z_r--(hP,.55fH);
- cdw (qP,.18aH)..(.65aW,1.3hP)..(fW,.4aH)..(hW,.63aH)..(.7hP,.56aH);
+ ef s="5": dwh Z_q--Z_u-(hP,0); dwv Z_r--(hP,.55fH);
+ cdw (qP,.25aH)..(.65aW,1.3hP)..(fW,.4aH)..(hW,.63aH)..(.7hP,.56aH);
ef s="6": dw Z_x..(fW,.5fW)..Z_i..(hP,.5fW)..cycle; cdw (.8fP,hH)--Z_f;
ef s="7": dwh (0,.fH)--Z_u; dwvs(1.2)(aW-1.2hP,aH-fP)--(.4aW,0);
ef s="8": dw circ_Oh; dw (hP,.75aH)...Z_s...(fW,.75aH)...Z_y...cycle;
@@ -1175,29 +1206,37 @@ def draw_char(expr s,p)=
fi
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-def warning_bond(expr a)=
+def warn_valence(expr a)=
if addA[a]=0:
- warning("A"&decimal(a)&" ( "&fsl(8)(str_tbl[strA[a]])&") has"&fdr(2)(bond_cntA)&" bonds");
+ warning_s[incr warning_cnt]:="!Strange valence "&str_tbl[strA[a]]&"(A"&decimal(a)&") has"&
+ fdr(2)(bond_cntA)&" bonds";
+ message "["&decimal(fig_num)&"]"&warning_s[warning_cnt]; message "";
fi
enddef;
%-------------------------------------------------------------------------------------------------
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
+ temps:=""; nA:=length(s);
+ if (nA>=4)and(s<>"COOH"):
+ for i=1 upto nA:
+ tempc:=substring(i-1,i) of s;
+ if scan_c(tempc,"{}_^+")=0: temps:=temps&tempc; fi
+ endfor
+ temps
else: s
fi
enddef;
%-------------------------------------------------------------------------------------------------
-vardef forbidden_to_underbar(expr t)= sS:="";
- for i=1 upto length(t):
- sC:=subc(i,t); if scan_c(sC,forbiddens)>0: sS:=sS&"_"; else: sS:=sS&sC; fi
+vardef forbidden_to_underbar(expr s)=
+ temps:=""; nA:=length(s);
+ for i=1 upto nA:
+ tempc:=substring(i-1,i) of s;
+ if scan_c(tempc,forbiddens)>0: temps:=temps&"_"; else: temps:=temps&tempc; fi
endfor
- sS
+ temps
enddef;
%=================================================================================================
def proc_calc(expr n)=
- MW_n:=MI_n:=tbl_atom_max:=warning_cnt:=hideH_cnt:=0; nE:=pcode_emb_start;
+ MW_n:=MI_n:=tbl_atom_max:=warning_cnt:=hideH_cnt:=0; nA:=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];
@@ -1206,23 +1245,23 @@ def proc_calc(expr n)=
if (sB[j]=i)or(eB[j]=i): bond_cntA:=bond_cntA+bond_num[j]; fi
endfor
Bcnt[i]:=bond_cntA;
- if ((nS=0)or(nS=(C-nE)))and(bond_cntA<4):
+ if ((nS=0)or(nS=(C-nA)))and(bond_cntA<4):
hideH[i]:=4-bond_cntA; hideH_cnt:=hideH_cnt+hideH[i]; else: hideH[i]:=0;
fi
- if nS=0: if bond_cntA>4: warning_bond(i) fi
- ef nS=(O-nE): if bond_cntA<>2: warning_bond(i) fi
- ef nS=(N-nE): if (bond_cntA<>3)and(bond_cntA<>5): warning_bond(i) fi
- ef nS=(S-nE): if (bond_cntA<>2)and(bond_cntA<>4)and(bond_cntA<>6): warning_bond(i) fi
- ef nS=(H-nE): if bond_cntA<>1: warning_bond(i) fi
- ef nS=(OH-nE): if bond_cntA<>1: warning_bond(i) fi
- ef nS=(COOH-nE): if bond_cntA<>1: warning_bond(i) fi
- ef nS=(NH2-nE): if bond_cntA<>1: warning_bond(i) fi
- ef nS=(CN-nE): if bond_cntA<>1: warning_bond(i) fi
- ef nS=(P-nE): if bond_cntA<>5: warning_bond(i) fi
- ef nS=(C-nE): if bond_cntA>4: warning_bond(i) fi
- ef nS=(F-nE): if bond_cntA<>1: warning_bond(i) fi
- ef nS=(Cl-nE): if bond_cntA<>1: warning_bond(i) fi
- ef nS=(Br-nE): if bond_cntA<>1: warning_bond(i) fi
+ if nS=0: if bond_cntA>4: warn_valence(i) fi
+ ef nS=(O-nA): if bond_cntA<>2: warn_valence(i) fi
+ ef nS=(N-nA): if (bond_cntA<>3)and(bond_cntA<>5): warn_valence(i) fi
+ ef nS=(S-nA): if (bond_cntA<>2)and(bond_cntA<>4)and(bond_cntA<>6): warn_valence(i) fi
+ ef nS=(H-nA): if bond_cntA<>1: warn_valence(i) fi
+ ef nS=(OH-nA): if bond_cntA<>1: warn_valence(i) fi
+ ef nS=(COOH-nA): if bond_cntA<>1: warn_valence(i) fi
+ ef nS=(NH2-nA): if bond_cntA<>1: warn_valence(i) fi
+ ef nS=(CN-nA): if bond_cntA<>1: warn_valence(i) fi
+ ef nS=(P-nA): if bond_cntA<>5: warn_valence(i) fi
+ ef nS=(C-nA): if bond_cntA>4: warn_valence(i) fi
+ ef nS=(F-nA): if bond_cntA<>1: warn_valence(i) fi
+ ef nS=(Cl-nA): if bond_cntA<>1: warn_valence(i) fi
+ ef nS=(Br-nA): if bond_cntA<>1: warn_valence(i) fi
fi
for j=1 upto tbl_group_end:
if str_tbl[nS]=tbl_atom_str[j]:
@@ -1237,7 +1276,7 @@ def proc_calc(expr n)=
fi
exitif knownA=1;
endfor
- if knownA=0: warning(" Unknown Str("&str_tbl[strA[i]]&") is used "&decimal(i)); fi
+ if knownA=0: message " 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
@@ -1251,56 +1290,58 @@ def proc_calc(expr n)=
enddef;
%=================================================================================================
def proc_report_out=
+ block_cnt_s:=split_str(mc,",")(block_s);
file_output:=jobname&"-report.txt";
- printf "===========================================================================";
- printf " No["&decimal(fig_num)&"],Name<"& EN&">,Category<"&CAT&">,File<"&file_input&">";
- 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)&"],"&
+ puts "===========================================================================";
+ puts " No["&decimal(fig_num)&"],Name<"& EN&">,Category<"&CAT&">,File<"&file_input&">";
+ puts "---------------------------------------------------------------------------";
+ puts " Row["&decimal(mc_row)&"],Length["&decimal(length(mc))&"],Block"&
+ "["&decimal(block_cnt_s)&"]"&",BackboneA["&decimal(backboneA)&"]"&
+ ",BackboneB["&decimal(backboneB)&"]"&",Group["&decimal(group_num)&"]";
+ puts "---------------------------------------------------------------------------";
+ for i=1 upto mc_row: puts (substring(0,mc_indent[i]) of blanks)&mc[i]; endfor
+ puts "---------------------------------------------------------------------------";
+ for i=1 upto block_cnt_s: puts "["&fdl(3)(i)&"] "&block_s[i]; endfor
+ puts "- unknown and warning -----------------------------------------------------";
+ for i=1 upto unknown_cnt: puts unknown_s[i]; endfor
+ for i=1 upto warning_cnt: puts warning_s[i]; endfor
+ puts "---------------------------------------------------------------------------";
+ puts " Width["&fdr(8)(mol_wd)&"],Height["&fdr(8)(mol_ht)&"],"&
" Shift x["& fdr(8)(minX)&"],Shift y["&fdr(8)(minY)&"]";
- printf " Bond length["&fdr(8)(blen)&"],Atom size["&fdr(8)(atom_wd)&"]";
- printf "---------------------------------------------------------------------------";
- printf " Atom["&decimal(cntA)&"],Bond["&decimal(cntB)&
+ puts " Bond length["&fdr(8)(blen)&"],Atom size["&fdr(8)(atom_wd)&"]";
+ puts "---------------------------------------------------------------------------";
+ puts " Atom["&decimal(cntA)&"],Bond["&decimal(cntB)&
"],Ring["&decimal(cntB-cntA+1)&"],Hide H["&decimal(hideH_cnt)&"]";
- printf "< NO. ><atom(s) >( x axis , y axis )<bond><hideH><chg>";
+ puts "< NO. ><atom(s) >( x axis , y axis )<bond><hideH><chg>";
for i=1 upto cntA:
- printf " A"&fdl(6)(i)&fsl(8)(erase_char(str_tbl[strA[i]]))&
+ puts " 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
- printf "---------------------------------------------------------------------------";
- printf "< NO. >< bond (sdt)><angle +( +- )><length ( pt )>";
+ puts "---------------------------------------------------------------------------";
+ puts "< NO. >< bond (sdt)><angle +( +- )><length ( pt )>";
for i=1 upto cntB:
nC:=lenB[i]; if nC=_size_atom: nC:=ratio_atom_bond; elseif nC<0: nC:=-nC; fi
nB:=angB[i]; if nB>180: nB:=nB-360; fi
- printf " B"&fdl(4)(i)&fdr(3)(sB[i])&" -> "&fdr(3)(eB[i])&
+ puts " 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
- printf "---------------------------------------------------------------------------";
- printf "<atom>( atom wt )[ mi wt ] < cnt > < sum wt >[ sum mi wt ]";
+ puts "---------------------------------------------------------------------------";
+ puts "<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]))&
+ puts " "&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
endfor
- printf " Molecular Weight [Mono Isotopic] = "&fsr(12)(mw)&"["&fsr(12)(MI)&"]";
- printf "---------------------------------------------------------------------------";
- 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 "===========================================================================";
+ puts " Molecular Weight [Mono Isotopic] = "&fsr(12)(mw)&"["&fsr(12)(MI)&"]";
+ puts "---------------------------------------------------------------------------";
+ puts " Weight Calc: "&mw if MW<>"-": &" - Input: "&MW&" = "&fdr(9)(MW_n-scantokens(MW)) fi;
+ puts " Fomula Calc: "&fm if FM<>"-": &" "&iif(fm=FM,"=","<>")&" Data: "&FM fi;
+ puts "===========================================================================";
enddef;
%=================================================================================================
def proc_mol_out(expr n)=
@@ -1308,54 +1349,54 @@ def proc_mol_out(expr n)=
file_output:="m"&fit_zero(fig_num)&"-"&EN_&".mol";
%-V2000---------------------------------------------------------------------------------------
if n=2000:
- printf ""; printf " -MCFtoMOL- "&fsl(20)(EN); printf "";
- printf fdr(3)(cntA)&fdr(3)(cntB)&" 0 0 0 0 0 0 0 0999 V2000";
+ puts ""; puts " -MCFtoMOL- "&fsl(20)(EN); puts "";
+ puts fdr(3)(cntA)&fdr(3)(cntB)&" 0 0 0 0 0 0 0 0999 V2000";
for i=1 upto cntA:
- printf fdr(10)(xpart(posA[i])/blen)& fdr(10)(ypart(posA[i])/blen)&fdr(10)(0)&" "&
+ puts fdr(10)(xpart(posA[i])/blen)& fdr(10)(ypart(posA[i])/blen)&fdr(10)(0)&" "&
fsl(2)(erase_char(str_tbl[strA[i]]))&" 0"&fdr(3)(bond_charge(chargeA[i]))&" 0 0";
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]))&
+ if lineB[i]<>0: puts fdr(3)(sB[i])&fdr(3)(eB[i])&fdr(3)(bond_type(lineB[i]))&
fdr(3)(bond_stereo(lineB[i]))&" 0 0";
fi
endfor
- printf "M END";
+ puts "M END";
%-V3000---------------------------------------------------------------------------------------
elseif n=3000:
- printf ""; printf " -MCFtoMOL- "&fsl(20)(EN); printf "";
- printf " 0 0 0 0 0 0 0 0 0 0 0 V3000";
- printf "M V30 BEGIN CTAB";
- printf "M V30 COUNTS "&decimal(cntA)&" "&decimal(cntB)&" 0 0 0";
- printf "M V30 BEGIN ATOM";
+ puts ""; puts " -MCFtoMOL- "&fsl(20)(EN); puts "";
+ puts " 0 0 0 0 0 0 0 0 0 0 0 V3000";
+ puts "M V30 BEGIN CTAB";
+ puts "M V30 COUNTS "&decimal(cntA)&" "&decimal(cntB)&" 0 0 0";
+ puts "M V30 BEGIN ATOM";
for i=1 upto cntA:
- printf "M V30 "&decimal(i)&" "&erase_char(str_tbl[strA[i]])&" "&
+ puts "M V30 "&decimal(i)&" "&erase_char(str_tbl[strA[i]])&" "&
decimal(xpart(posA[i])/blen)&" "&decimal(ypart(posA[i])/blen)&" 0 0"
if chargeA[i]<>0: &" CHG="&decimal(chargeA[i]) fi;
endfor
- printf "M V30 END ATOM"; printf "M V30 BEGIN BOND";
+ puts "M V30 END ATOM"; puts "M V30 BEGIN BOND";
for i=1 upto cntB:
if lineB[i]<>0:
- printf "M V30 "&decimal(i)&" "&decimal(bond_type(lineB[i]))&
+ puts "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
endfor
- printf "M V30 END BOND"; printf "M V30 END CTAB"; printf "M END"; fi
+ puts "M V30 END BOND"; puts "M V30 END CTAB"; puts "M END"; fi
enddef;
%=================================================================================================
def proc_mc_out=
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:="";
+ nB:=split_str(mc,",")(arg_s); nA:=0; temps:="";
+ for i=1 upto nB:
+ if i=nB: temps:=temps&arg_s[i]; puts temps;
+ ef at_char[i+1]-nA>mc_length: nA:=at_char[i]; puts 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
+ else: for i=1 upto mc_row: puts (substring(0,mc_indent[i]) of blanks)&mc[i]; endfor
fi
- printf EOF;
+ puts EOF;
enddef;
%=================================================================================================
vardef fit_zero(expr n)= if n<=9: "00" ef n<=99: "0" else: "" fi &decimal(n) enddef;
@@ -1416,7 +1457,13 @@ def define_atom_group_parts=
NO_ATOM:=`("",0,0);
tbl_atom_end:=tbl_cnt;
%-----------------------------------------------------------------------------------------------
- if sw_expand=0:
+ !:=!1:='((_mk_bond,_arrange_ang));
+ 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);
+ else:
CH3:=``("C{H_3_}")(C,H,H,H); CH2:=``("C{H_3_}")(C,H,H); CN:=``("CN")(C,N); OH:=``("OH")(O,H);
COOH:=``("COOH")(C,O,O,H); COONa:=``("COO{Na}")(C,O,O,Na); CHO:=``("CHO")(C,H,O);
NO:=``("NO")(N,O); NO2:=``("N{O_2_}")(N,O,O); NH2:=``("N{H_2_}")(N,H,H);
@@ -1426,38 +1473,29 @@ def define_atom_group_parts=
%-----------------------------------------------------------------------------------------------
tbl_group_end:=tbl_cnt; pcode_atm_end:=pcode_num;
?:='((_group_si,NO_ATOM)); ?wf:=?w:='((_group_wf,NO_ATOM)); ?zf:=?z:='((_group_zf,NO_ATOM));
- ?O:='((_group_dm,O)); NH:='(N,/H~nl); ?NH:='((_group_dm,NH));
+ ?dm:=?d:='((_group_dm,NO_ATOM)); ?O:='((_group_dm,O)); ?S:='((_group_dm,S)); NH:='(N,/H~nl);
+ ?NH:='((_group_dm,NH));
%-----------------------------------------------------------------------------------------------
?H:='(/H); ?F:='(/F); ?Cl:='(/Cl); ?OH:='(/OH); ?OH:='(/COOH); ?NH2:='(/NH2);
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: for j=11 upto 15: ?[i][j]:='((i,j)); endfor endfor
%-----------------------------------------------------------------------------------------------
- !:=!1:='((_mk_bond,_arrange_ang)); !db:=!d:='(!~db); !tm:=!t:='(!~tm); !wf:=!w:='(!~wf);
- !zf:=!z:='(!~zf); !wb:='(!~wb); !zb:='(!~zb); !dl:='(!~dl); !dr:='(!~dr); !dm:='(!~dm);
+ !db:=!d:='(!~db); !tm:=!t:='(!~tm); !wf:=!w:='(!~wf); !zf:=!z:='(!~zf); !wb:='(!~wb);
+ !zb:='(!~zb); !dl:='(!~dl); !dr:='(!~dr); !dm:='(!~dm);
for i==2 upto 20:
![i]:='((_com,_len_ss),(_get_len,_tmp_len),! for j==2 upto i::,! endfor ,(_com,_len_ee));
endfor
- ?!:='(/_,!); ?!d:='(/_,!d); ?!2:='(/_,!2); ??!:='(/_,/_^60,60); ??:='(/_^35,/_^-35);
- !?:='(!,/_); !?!:='(!?,!); !??!:='(!,??,!); ?2:='(/!); !?2:='(!,?2); ?2!:='(?2,!);
+ ?!:='(?,!); ?!d:='(?,!d); ?!2:='(?,!2); ??!:='(?,?^60,60); ??:='(?^35,?^-35);
+ !?:='(!,?); !?!:='(!?,!); !??!:='(!,??,!); ?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));
%-----------------------------------------------------------------------------------------------
- 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
- %-----------------------------------------------------------------------------------------------
- ?F!F:='(/F,60,F); ?Cl!Cl:='(/Cl,60,Cl); ?Br!Br:='(/Br,60,Br); ?F?F!F:='(/F,/F^60,60,F);
+ ?F!F:='(/F,60,F); ?F?F!F:='(/F,/F^60,60,F); ?Br!Br:='(/Br,60,Br); ?Cl!Cl:='(/Cl,60,Cl);
?Cl?Cl!Cl:='(/Cl,/Cl^60,60,Cl);
%-----------------------------------------------------------------------------------------------
- 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);
+ N!:='(N,!); N?:='(N,?); N!2:='(N,!3); N!2:='(N,!3); !N:='(!,N); N?!:='(N,?!); 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);
%-----------------------------------------------------------------------------------------------
@@ -1465,10 +1503,8 @@ def define_atom_group_parts=
NH!:='(NH,!); NH!2:='(NH,!2); !NH:='(!,NH); !NH!:='(!,NH!);
%-----------------------------------------------------------------------------------------------
!OH:='(!,OH); !SH:='(!,SH); !NH2:='(!,NH2); !S?O:='(!,S?O); !O:='(!,O); !dO:='(!d,O);
- !O!:='(!,O!); !O!2:='(!,O!2); !O!3:='(!,O!3); !S!:='(!,S!); !S!2:='(!,S!2); !S!3:='(!,S!3);
+ !Cl:='(!,Cl); !Br:='(!,Br); !F:='(!,F); !O!:='(!,O!); !S!:='(!,S!);
!COOH:='(!,COOH); ?COOH:='(/COOH); !CH3:='(!,CH3); !CN:='(!,CN); !CHO:='(!,CHO); !NO2:='(!,NO2);
- !Cl:='(!,Cl); !Br:='(!,Br); !F:='(!,F); !?F!F:='(!,?F!F); !?Cl!Cl:='(!,?Cl!Cl);
- !?F?F!F:='(!,?F?F!F); !?Cl?Cl!Cl:='(!,?Cl?Cl!Cl);
!?3:='(!,?3); !?4:='(!,?4); !?5:='(!,?5); !?6:='(!,?6); !?7:='(!,?7); !?8:='(!,?8);
!Ph:='(!,Ph); !?OH:='(!,?OH); ?OH!:='(?OH,!);
%-----------------------------------------------------------------------------------------------
@@ -1488,25 +1524,27 @@ message "pcode_emb =" & decimal(pcode_emb_start) &" => " & decimal(pcode_num) &
message "pcode_emi =" & decimal(pcode_emi_start) &" => " & decimal(pcode_int);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vardef checkm(expr s)=
- save mc_char,mc_adr,mc_asc,char_cnt,lens,f_depth;
- string err_type[];
+ save mc_char,mc_adr,mc_asc,err_type,char_cnt,lens,f_exit;
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 ";
+ %---------------------------------------------------------------------------------------------
+ string err_type[];
+ err_cnt:=char_cnt:=0; nA:=1; lens:=length(s);
+ err_type[0]:="Error no mc-row "; err_type[1]:="Error mismatch ()";
+ err_type[2]:="Error mismatch {}"; err_type[4]:="Error missing arg";
+ err_type[5]:="Error extra arg ";
%---------------------------------------------------------------------------------------------
if mc_row>=1:
for i=1 upto 128: tbl_asc[i]:=0; endfor
- for i=1 upto lens: mc_char[i]:=ASCII(subc(i,s)); endfor
+ for i=1 upto lens: mc_char[i]:=ASCII(substring(i-1,i) of s); endfor
forever:
- temps:=substring (nA-1,nA) of s;
- if (temps<>",")and(temps<>" "): nF:=0;
- for j=1 upto rw_cnt: nC:=lenw[j]-1;
+ tempc:=substring (nA-1,nA) of s;
+ if (tempc<>",")and(tempc<>" "): f_exit:=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;
+ for k=1 upto nC: mc_char[nA]:=j; mc_char[nA+k]:=BLK; endfor nA:=nA+nC; f_exit:=1;
fi
- exitif nF=1;
+ exitif f_exit=1;
endfor
fi
nA:=nA+1; exitif nA>=lens;
@@ -1518,21 +1556,19 @@ vardef checkm(expr s)=
%-- 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
+ if (nB=EQU)or(nB=CLN)or(nB=HAT)or(nB=BQT)or(nB=TLD)or(nB=LTN)or(nB=QUT): % =,:,^,`,~,>,'
+ if (nA=CMA)or(nC=CMA)or(nA=QUT)or(nC=QUT): proc_err(4,i) fi
+ ef (nB=AMK)or(nB=AMP)or(nB=GTN): % @,&,<,$
+ if nA<>CMA: proc_err(5,nB) fi if (nC=CMA)or(nC=QUT): proc_err(4,i) fi
+ ef (nB=SLS)or((nB>=1)and(nB<=5)):
+ if (nA<>CMA)and(nA<>CLN)and(nA<>PRS): proc_err(5,i) fi % /,*/*,//,/*,*/,**
+ if (nC=CMA)or(nC=QUT): proc_err(4,i) fi
+ ef nB=DOL: if (nC=QUT)or(nC=CMA): proc_err(4,i) fi
fi
- 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 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
%---------------------------------------------------------------------------------------------
%%%%%%% err_cnt>0: readstring;
@@ -1541,26 +1577,25 @@ enddef;
%-------------------------------------------------------------------------------------------------
def proc_err(expr e,n)=
err_cnt:=err_cnt+1;
- message "["&decimal(fig_num)&"]:"&err_type[e]
+ 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)=
file_output:=s;
- for i=1 upto ucount: for j=1 upto unit_lines[i]: printf row[i][j]; endfor endfor
+ for i=1 upto ucount: for j=1 upto unit_lines[i]: puts row[i][j]; endfor endfor
closefrom file_output;
enddef;
%-------------------------------------------------------------------------------------------------
def loadm(text s)=
begingroup
- save f_mcf,f_line,lines,unit_cnt,row_s,row_cnt,semic_cnt,info_cnt,order,min_n,max_n,firstc,
- sign_at,sign_n,filter_n,filter_tag,filter_var,filter_sign,filter_cnt,filter_p,lib_unit_cnt,
- at_colon,at_equal,at_less,at_greater,at_n,sort_tbl,key_s,sort_s,sign_s,sV,sS,sT,sort_oder,
- tag_s,val_s;
- string row_s[][],sort_s,sort_tbl[],key_s,filter_tag[],filter_var[],sign_s[],sV,sS,sT,firstc,
- tag_s[][],val_s[][];
+ save f_mcf,lines,unit_cnt,row_s,row_cnt,info_cnt,order,min_n,max_n,sign_at,sign_n,tag_s,
+ val_s,filter_n,filter_tag,filter_val,filter_sign,filter_cnt,filter_p,lib_unit_cnt,at_colon,
+ at_equal,at_less,at_greater,at_n,sort_tbl,key_s,sort_s,sign_s,sV,sT,sort_oder;
+ string row_s[][],sort_s,sort_tbl[],key_s,filter_tag[],filter_val[],sign_s[],tag_s[][],val_s[][],
+ sV,sT;
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;
+ lines:=f_mcf:=mc_row:=info_cnt:=filter_cnt:=lib_unit_cnt:=0; unit_cnt:=1;
file_input:=default_library;
sign_s1:="="; sign_s2:="<>"; sign_s3:="<"; sign_s4:=">"; sign_s5:="<="; sign_s6:=">=";
%-----------------------------------------------------------------------------------------------
@@ -1571,27 +1606,36 @@ def loadm(text s)=
if at_colon>=2: sign_at:=at_colon; sign_n:=0; at_n:=1;
ef at_equal>=2: if (at_equal-1)=at_less: sign_at:=at_equal; sign_n:=5; at_n:=2;
ef (at_equal-1)=at_greater: sign_at:=at_equal; sign_n:=6; at_n:=2;
- else: sign_at:=at_equal; sign_n:=1; at_n:=1; fi
+ 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
- sT:=substring(0,sign_at-at_n) of list; sV:=substring(sign_at,length(list)) of list;
+ 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
+ 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
+ filter_tag[incr filter_cnt]:=sT;
+ filter_sign[filter_cnt]:=sign_n;
+ if (sign_n>=3)and(is_num(sV)=1): filter_val[filter_cnt]:=fix_num(sV);
+ else: filter_val[filter_cnt]:=sV;
+ fi
fi
endfor
%-----------------------------------------------------------------------------------------------
forever:
- temps:=readfrom file_input; exitif temps=EOF; firstc:=subc(1,temps);
+ line_s:=readfrom file_input;
+ exitif line_s=EOF;
+ firstc:=substring(0,1) of line_s;
if (firstc<>"%")or(sw_comment=1):
- row_s[unit_cnt][incr lines]:=temps;
+ row_s[unit_cnt][incr lines]:=line_s;
if firstc=";":
row_cnt[unit_cnt]:=lines; f_mcf:=lines:=0; filter_n:=1;
for i=1 upto filter_cnt: filter_p[i]:=0; endfor
@@ -1603,13 +1647,13 @@ def loadm(text s)=
for j=1 upto filter_cnt:
if filter_tag[j]=sT:
filter_p[j]:=1;
- if (filter_sign[j]>=3)and(is_num(sV)=1): temps:=fix_num(sV); else: temps:=sV; fi
- if filter_sign[j]=1: if not(temps= filter_var[j]): filter_n:=0; fi
- ef filter_sign[j]=2: if not(temps<>filter_var[j]): filter_n:=0; fi
- ef filter_sign[j]=3: if not(temps< filter_var[j]): filter_n:=0; fi
- ef filter_sign[j]=4: if not(temps> filter_var[j]): filter_n:=0; fi
- ef filter_sign[j]=5: if not(temps<=filter_var[j]): filter_n:=0; fi
- ef filter_sign[j]=6: if not(temps>=filter_var[j]): filter_n:=0; fi
+ if (filter_sign[j]>=3)and(is_num(sV)=1): line_s:=fix_num(sV); else: line_s:=sV; fi
+ if filter_sign[j]=1: if not(line_s= filter_val[j]): filter_n:=0; fi
+ ef filter_sign[j]=2: if not(line_s<>filter_val[j]): filter_n:=0; fi
+ ef filter_sign[j]=3: if not(line_s< filter_val[j]): filter_n:=0; fi
+ ef filter_sign[j]=4: if not(line_s> filter_val[j]): filter_n:=0; fi
+ ef filter_sign[j]=5: if not(line_s<=filter_val[j]): filter_n:=0; fi
+ ef filter_sign[j]=6: if not(line_s>=filter_val[j]): filter_n:=0; fi
fi
fi
endfor
@@ -1619,7 +1663,8 @@ 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(line_s,";")(arg_s);
fi
fi
fi
@@ -1627,10 +1672,10 @@ def loadm(text s)=
ucount:=unit_cnt:=unit_cnt-1;
%=============================================================================================
message "* Input : "&file_input&" ["&decimal(lib_unit_cnt)&"]";
- message "* Output : ucount ["&decimal(ucount)&"]";
+ message "* Output : ucount ["&decimal(ucount)&"]"; message "";
if filter_cnt>=1:
for i=1 upto filter_cnt:
- message "* Filter("&decimal(i)&"): "&filter_tag[i]&" "&sign_s[filter_sign[i]]&filter_var[i];
+ message "* Filter("&decimal(i)&"): "&filter_tag[i]&" "&sign_s[filter_sign[i]]&filter_val[i];
endfor
if key_s<>"": message "* Sort key : "&key_s&iif(sort_oder=0," (ascending)"," (descending)");
fi
@@ -1639,14 +1684,14 @@ def loadm(text s)=
if key_s<>"":
for i=1 upto unit_cnt: order[i]:=0; endfor
for i=1 upto unit_cnt:
- if sort_oder=0: temps:="~";
+ if sort_oder=0: line_s:="~";
for j=1 upto unit_cnt:
- if order[j]=0: if sort_tbl[j]<temps: temps:=sort_tbl[j]; min_n:=j; fi fi
+ if order[j]=0: if sort_tbl[j]<line_s: line_s:=sort_tbl[j]; min_n:=j; fi fi
endfor
order[min_n]:=i; order_tbl[i]:=min_n;
- ef sort_oder=1: temps:=" ";
+ ef sort_oder=1: line_s:=" ";
for j=1 upto unit_cnt:
- if order[j]=0: if sort_tbl[j]>temps: temps:=sort_tbl[j]; max_n:=j; fi fi
+ if order[j]=0: if sort_tbl[j]>line_s: line_s:=sort_tbl[j]; max_n:=j; fi fi
endfor
order[max_n]:=i; order_tbl[i]:=max_n;
fi
@@ -1672,16 +1717,17 @@ def loadm(text s)=
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;
+ temps:=s; nN:=scan_c(".",temps);
+ if nN=0: temps:=fsr(4)(temps); ef nN=1: temps:=" 0"&temps;
+ ef nN=2: temps:=" "&temps; ef nN=3: temps:=" "&temps; ef nN=4: temps:=" "&temps;
fi
- sS
+ temps
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
+ tempc:=substring(i-1,i) of s;
+ if ((tempc>="0")and(tempc<="9"))or(tempc="."): nN:=1; else: nN:=0; fi
endfor
nN
enddef;
@@ -1689,19 +1735,24 @@ 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
+ nN:=0; nA:=length(s);
+ if d=0: for i=n upto nA: if substring(i-1,i) of s=c: nN:=i; fi exitif nN>0; endfor
+ ef d=1: for i=n upto nA: if substring(i-1,i) of s<>c: nN:=i; fi exitif nN>0; endfor
+ ef d=-1: for i=nA downto n: if substring(i-1,i) of 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 scan_c(expr c,s)=
+ nN:=0; nA:=length(s);
+ for i=1 upto nA: if substring(i-1,i) of s=c: nN:=i; fi exitif nN>0; endfor
+ nN
+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;
+ at_char[0]:=nN:=0; nA:=length(s);
+ for i=1 upto nA: if substring(i-1,i) of s=c: at_char[incr nN]:=i; fi endfor
+ at_char[incr nN]:=nA+1;
for i=1 upto nN: v[i]:=substring (at_char[i-1],at_char[i]-1) of s; endfor
nN
enddef;