diff options
author | Karl Berry <karl@freefriends.org> | 2021-09-20 20:04:12 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-09-20 20:04:12 +0000 |
commit | d291f73c830f767b003eabd72656e171ef0e4597 (patch) | |
tree | 0560c04ba73ece5422c6c62ab13119d7f248304d /Master/texmf-dist/metapost | |
parent | 0bdaeca85d17f4f21e9b485d39fdebf884725107 (diff) |
mcf2graph (20sep21)
git-svn-id: svn://tug.org/texlive/trunk@60565 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 617 |
1 files changed, 328 insertions, 289 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index ff1cb14b3d0..2dfefbba648 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 4.71 Copyright (c) 2013-2021 Akira Yamaji +% mcf2graph ver 4.72 Copyright (c) 2013-2021 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,42 +22,44 @@ % This package is located at : http://www.ctan.org/pkg/mcf2graph % Suggestion or request mail to : mcf2graph@gmail.com %-------------------------------------------------------------------------------------------------- -% Set outputformat to "eps"(.mps) : mpost FILENAME -% Set output first font only : mpost -s bboxmargin=1 FILENAME -% Set outputformat to "png" : mpost -s ahangle=1 FILENAME -% Set outputformat to "svg" : mpost -s ahangle=2 FILENAME -% Set outputformat to "eps" (.eps) : mpost -s ahangle=3 FILENAME -% Set output aux file (tag1:var1;tag2:var2) : mpost -s ahlength=1 FILENAME -% Set output aux file (tag1;tag2 var1;var2) : mpost -s ahlength=2 FILENAME -% Set output report : mpost -s ahlength=3 FILENAME -% Set output MOL(V2000) : mpost -s ahlength=5 FILENAME -% Set output MOL(V3000) : mpost -s ahlength=6 FILENAME -% Set output aux file for metafont : mpost -s ahlength=7 FILENAME -% Set to use plain.mp (label,arrow) : mpost -s labeloffset=1 FILENAME -% Set to use plain.mp (label,arrow,atom) : mpost -s labeloffset=2 FILENAME +% Set outputformat to "eps"(.mps) : mpost FILENAME +% Set output first font only : mpost -s bboxmargin=1 FILENAME +% Set outputformat to "png" : mpost -s ahangle=1 FILENAME +% Set outputformat to "svg" : mpost -s ahangle=2 FILENAME +% Set outputformat to "eps" (.eps) : mpost -s ahangle=3 FILENAME +% Set output information aux file (tag1:var1;tag2:var2) : mpost -s ahlength=1 FILENAME +% Set output information aux file (tag1;tag2 var1;var2) : mpost -s ahlength=2 FILENAME +% Set output report : mpost -s ahlength=3 FILENAME +% Set output MOL file (V2000) : mpost -s ahlength=5 FILENAME +% Set output MOL file (V3000) : mpost -s ahlength=6 FILENAME +% Set output aux metafont file : mpost -s ahlength=7 FILENAME +% Set output aux data-base file : mpost -s ahlength=8 FILENAME +% Set to use plain.mp (label,arrow) : mpost -s labeloffset=1 FILENAME +% Set to use plain.mp (label,arrow,atom) : mpost -s labeloffset=2 FILENAME %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tracingstats:=1; -message "* This is mcf2graph ver 4.71 2021.09.05"; +message "* This is mcf2graph ver 4.72 2021.09.20"; %------------------------------------------------------------------------------------------------- newinternal cntA,cntB,cntM,minX,minY,maxX,maxY,sftX,sftY,com,par,envT,envB,lenT,lineT,angT,rotT, crR,nA,nB,nC,nD,nE,nF,nS,nL,nR,nU,nP,xpos,ypos,markA,markB,saveA,saveB,bondL; numeric save_num[],comD[][],parD[][],adrD[][],cntD[],tbl_atom[],tbl_group[][],f_char[], tbl_atom_wt[],tbl_atom_mi[],tbl_char_wd[],tbl_char_ht[],addA[],add_rot[],chargeA[], com_group[][],par_group[][],cnt_group[],colorA[],colorB[],sumA[],bondC[],hideH[],lineB[], - sB[],eB[],angB[],angA[],lenB[],angX[],numS[],wdM[],htM[],wdA[],dxA[],cmm_adr[],mc_indent[]; + sB[],eB[],angB[],angA[],lenB[],angX[],numS[],wdM[],htM[],wdA[],dxA[], + cmm_adr[],mc_indent[],at_semicol[]; string save_str[],tbl_atom_str[],strD[],tag[],file_name_output,blank_str,aux_delimiter,atomfont, - default_data_file,default_temp_file,mpfont,s_tag,s_var,cal_FM,cal_MW,cal_MI, - inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW; + temps,default_data_file,default_temp_file,mpfont,tag_s,var_s,cal_FM,cal_MW,cal_MI, + inf_Cat,inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW; pair save_pair[],posA[],posM[][],msize,mposition,fsize,fmargin,save_mposition,posBs,posBe,dum; picture mol_stru[],atom_picture,save_picture,temp_picture; path arrow_path,dottedline_path,line_path,arrow_head; %------------------------------------------------------------------------------------------------- char_num:=str_cnt:=tbl_cnt:=proc_end:=mangle:=sw_expand:=sw_frame:=sw_trimming:=sw_ext_all:=0; -sw_abbreviate:=sw_arrow_emu:=sw_output:=sw_numbering:=0; numbering_start:=1; numbering_end:=4095; +sw_abbreviate:=sw_arrow_emu:=sw_numbering:=sw_output:=0; numbering_start:=1; numbering_end:=4095; %------------------------------------------------------------------------------------------------- aux_max:=max_inf_num:=20; aux_delimiter:=";"; blank_str:= " "; dum:=(-4091,0); for i=1 upto aux_max: tag[i]:=""; endfor -Font:=1; Temp:=2; Info:=4; Table:=8; Report:=16; MOL2k:=32; MOL3k:=64; Mfont:=128; Mcode:=256; +Font:=1; Mfont:=2; Mcode:=4; Temp:=8; Info:=16; Table:=32; Report:=64; MOL2k:=128; MOL3k:=256; Atom:=8; Bond:=16; Brock:=32; Inverse:=64; Group:=32; Mol:=64; Outside:=1; Inside:=2; Bothside:=Outside+Inside; %------------------------------------------------------------------------------------------------- @@ -110,11 +112,11 @@ if (known green)and(known ahlength): if ahlength=1: sw_output:=Info; % output aux file elseif ahlength=2: sw_output:=Info+Table; % output aux file(Table mode) elseif ahlength=3: sw_output:=Report; % output report - elseif ahlength=4: sw_output:=0; % *default + elseif ahlength=4: sw_output:=Font; % *default elseif ahlength=5: sw_output:=MOL2k; % output MOL(V2000) elseif ahlength=6: sw_output:=MOL3k; % output MOL(V3000) elseif ahlength=7: sw_output:=Mfont; % output aux mf - elseif ahlength=8: sw_output:=Mcode; % output aux mc + elseif ahlength=8: sw_output:=Mcode+Info; % output aux data-base fi %-- default bboxmargin=2------------------------------------------------------------------ if bboxmargin=1: proc_end:=1; fi % output first font only @@ -135,6 +137,31 @@ if (known green)and(known ahlength): if atomfont="": atomfont:="draw"; fi % default atom font if defaultfont="": defaultfont:="draw"; fi % default label font %----------------------------------------------------------------------------------------- + if sw_output>=Info: + if bboxmargin=1: message "* output first font only"; fi + message "* jobname="&jobname; + message "* numbersystem="&numbersystem; + if (ahlength=1)or(ahlength=2): + message "* output information file"; + message "* file name="&jobname&"-info.aux"; + message "* info delimiter="&aux_delimiter; + ef ahlength=3: message "* output report file"; + message "* file name="&jobname&"-report.txt"; + ef ahlength=5: message "* output MOL file(V2000)"; + message "* "&jobname&"-nnn-"&"inf_EN"&".mol"; + ef ahlength=6: message "* output MOL file(V3000)"; + message "* "&jobname&"-nnn-"&"inf_EN"&".mol"; + ef ahlength=7: message "* output metafont file"; + message "* mf file name="&jobname&"-mf.aux"; + ef ahlength=8: message "* output data-base file"; + message "* data-base file name="&jobname&"-data.aux"; + fi + message "* outputformat="&outputformat; + if outputformat="png": message "* hppp="&decimal(hppp)&"/vppp="&decimal(vppp); fi + message "* outputtemplate="&outputtemplate; + message "* atomfont="&atomfont; + message "* defaultfont="&defaultfont; + fi else: f_MP:=0; def image = image_emu enddef; @@ -149,34 +176,11 @@ else: def color = transform enddef; atomfont:="draw"; defaultfont:="draw"; + sw_output:=Font; mode_setup; fi clearit; %-------------------------------------------------------------------------------------------------- -if f_MP=1: - if bboxmargin=1: message "* output first font only"; fi - message "* jobname="&jobname; - message "* numbersystem="&numbersystem; - if (ahlength=1)or(ahlength=2): - message "* output info file"; - message "* file name="&jobname&"-info.aux"; - message "* info delimiter="&aux_delimiter; - ef ahlength=3: message "* output report file"; - message "* file name="&jobname&"-report.txt"; - ef ahlength=5: message "* output MOL file(V2000)"; - message "* "&jobname&"-nnn-"&"inf_EN"&".mol"; - ef ahlength=6: message "* output MOL file(V3000)"; - message "* "&jobname&"-nnn-"&"inf_EN"&".mol"; - ef ahlength=7: message "* output mf file"; - message "* mf file name="&jobname&"-mf.aux"; - fi - message "* outputformat="&outputformat; - if outputformat="png": message "* hppp="&decimal(hppp)&"/vppp="&decimal(vppp); fi - message "* outputtemplate="&outputtemplate; - message "* atomfont="&atomfont; - message "* defaultfont="&defaultfont; -fi -%-------------------------------------------------------------------------------------------------- ?3:=?20:=Ph:=Ph1:=Ph2:=hz:=0; vt:=1; 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; @@ -254,43 +258,47 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def beginfont(text s)= begingroup - save ',f_beginchar,f_ext,blen,ext,add,ang_br,n_fw,n_bw,at_colon,at_semicol,temps,t_tag, + save ',f_beginchar,f_ext,blen,ext,add,ang_br,fw_n,bw_n,at_colon,temp_tag, mc,info,file_name_input,bond_cnt,warning_cnt,hideH_cnt,bondC,filter_s; - numeric at_semicol[]; - string info[],mc[],mc,temps,file_name_input,t_tag,filter_s; + string info[],mc[],mc,file_name_input,temp_tag,filter_s; %------------------------------------------------------------------------------------------------ def ext=ext_to_font enddef; def add=add_to_molecule enddef; def '=read_ud enddef; %------------------------------------------------------------------------------------------------ - inf_NO:=inf_EN:=inf_JN:=inf_MW:=inf_FM:=inf_CAS:=inf_USE:=inf_EXA:=inf_EXB:="-"; - mc:=t_tag:=file_name_input:=cal_MW:=cal_MI:=cal_FM:=filter_s:=""; + inf_NO:=inf_EN:=inf_JN:=inf_MW:=inf_FM:=inf_CAS:=inf_Cat:=inf_EXA:=inf_EXB:="-"; + mc:=temp_tag:=cal_MW:=cal_MI:=cal_FM:=filter_s:=""; + file_name_input:=default_data_file; %------------------------------------------------------------------------------------------------ parts_cnt:=parts_usr_start; parts_int:=parts_int_start; %------------------------------------------------------------------------------------------------ char_num:=char_num+1; store_par(parameter_list); - f_ext:=cntM:=mc_row:=inf_num:=f_EOF:=f_close:=0; - for list=s: inf_num:=inf_num+1; info[inf_num]:=list; mc[inf_num]:=""; endfor + f_ext:=cntM:=mc_row:=inf_num:=f_EOF:=0; %------------------------------------------------------------------------------------------------ - for j=1 upto inf_num: - at_colon:=scan_char(":",info[j],0,1); + for list=s: + at_colon:=scan_char(":",list,0,1); if at_colon=1: - n_fw:=scan_char(" ",info[j],1,2); - n_bw:=scan_char(" ",info[j],-1,2); + fw_n:=scan_char(" ",list,1,2); + bw_n:=scan_char(" ",list,-1,2); mc_row:=mc_row+1; - mc_indent[mc_row]:=n_fw-2; - mc[mc_row]:=substring (n_fw-1,n_bw) of info[j]; + mc_indent[mc_row]:=fw_n-2; + mc[mc_row]:=substring (fw_n-1,bw_n) of list; mc:=mc&mc[mc_row]; ef at_colon>=1: - s_tag:=substring (0,at_colon-1) of info[j]; - s_var:=substring (at_colon,length(info[j])) of info[j]; - if s_tag="f": if f_MP=1: file_name_input:=s_var&".mcf"; f_close:=1; fi - ef s_tag="f+": if f_MP=1: file_name_input:=s_var&".mcf"; fi - ef s_tag="t": if f_MP=1: t_tag:=s_var; fi - ef s_tag="v": if f_MP=1: pickup_data_unit(t_tag,s_var); fi - else: if known scantokens("inf_"&s_tag): scantokens("inf_"&s_tag):=s_var; fi + tag_s:=substring (0,at_colon-1) of list; + var_s:=substring (at_colon,length(list)) of list; + if tag_s="f": + if f_MP=1: + if scan_char(".",var_s,0,1)=0: file_name_input:=var_s&".mcf"; + else: file_name_input:=var_s; + fi + fi + ef tag_s="t": if f_MP=1: temp_tag:=var_s; fi + ef tag_s="v": if f_MP=1: pickup_data_unit(temp_tag,var_s,1); fi + ef tag_s="v+": if f_MP=1: pickup_data_unit(temp_tag,var_s,0); fi + else: if known scantokens("inf_"&tag_s): scantokens("inf_"&tag_s):=var_s; fi fi fi endfor @@ -299,88 +307,89 @@ def beginfont(text s)= enddef; %================================================================================================== def endfont= - %-------------------------------------------------------------------------------------------- if f_EOF=0: - %-------------------------------------------------------------------------------------------- - if (sw_output=0)or(scan_bit(sw_output,Font)): - if cntM>=1: - if sw_ext_all=1: ext_to_font(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 - font_wd:=nB-nA+2margin_lr; - font_ht:=nD-nC+2margin_tb; - fsize:=(font_wd,font_ht); + %-------------------------------------------------------------------------------------------- + if scan_bit(sw_output,Font): + if cntM>=1: + if sw_ext_all=1: ext_to_font(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 + font_wd:=nB-nA+2margin_lr; + font_ht:=nD-nC+2margin_tb; + fsize:=(font_wd,font_ht); + for i=1 upto cntM: + posM[0][i]:=posM[0][i]+(margin_lr-nA,margin_tb-nC); + posM[1][i]:=posM[1][i]+(margin_lr-nA,margin_tb-nC); + endfor + fi + %---------------------------------------------------------------------------------------- + if f_MP=0: beginchar(char_num,font_wd/bp*bp#,font_ht/bp*bp#,0) + else: beginfig(char_num) w:=charwd:=font_wd; h:=charht:=font_ht; chardp:=0; + if scan_bit(sw_frame,Outside): else: draw_corner((0,0),w,h,0.05bp); fi + fi + if scan_bit(sw_frame,Outside): draw_frame((0,0),w,h,thickness_frame); fi + if scan_bit(sw_frame,Inside): + draw_frame((margin_lr,margin_tb),w-2margin_lr,h-2margin_tb,thickness_frame); + fi for i=1 upto cntM: - posM[0][i]:=posM[0][i]+(margin_lr-nA,margin_tb-nC); - posM[1][i]:=posM[1][i]+(margin_lr-nA,margin_tb-nC); + addto currentpicture also mol_stru[i] shifted posM[0][i]; mol_stru[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_stru[0]; mol_stru[0]:=nullpicture; fi + %---------------------------------------------------------------------------------------- + else: + font_wd:=xpart(fsize); font_ht:=ypart(fsize); + if f_MP=0: beginchar(char_num,font_wd/bp*bp#,font_ht/bp*bp#,0) + else: beginfig(char_num) w:=charwd:=font_wd; h:=charht:=font_ht; + fi + draw (0,h)--(0,0)--(w,0)--(w,h)--(0,h)--(w,0) wpcs thickness_frame; fi - %---------------------------------------------------------------------------------------- - if f_MP=0: beginchar(char_num,font_wd/bp*bp#,font_ht/bp*bp#,0) - else: beginfig(char_num) w:=charwd:=font_wd; h:=charht:=font_ht; chardp:=0; - if scan_bit(sw_frame,Outside): else: draw_corner((0,0),w,h,0.05bp); fi - fi - if scan_bit(sw_frame,Outside): draw_frame((0,0),w,h,thickness_frame); fi - if scan_bit(sw_frame,Inside): - draw_frame((margin_lr,margin_tb),w-2margin_lr,h-2margin_tb,thickness_frame); - fi - for i=1 upto cntM: - addto currentpicture also mol_stru[i] shifted posM[0][i]; mol_stru[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_stru[0]; mol_stru[0]:=nullpicture; fi %----------------------------------------------------------------------------------------- - else: - font_wd:=xpart(fsize); font_ht:=ypart(fsize); - if f_MP=0: beginchar(char_num,font_wd/bp*bp#,font_ht/bp*bp#,0) - else: beginfig(char_num) w:=charwd:=font_wd; h:=charht:=font_ht; + endchar; + clearit; + %----------------------------------------------------------------------------------------- + if sw_output=Font+Info+Temp: proc_info_out(1,1); + ef sw_output=Font+Mcode+Temp: proc_mc_out(1); + ef sw_output=Font+Info+Mcode+Temp: proc_info_out(1,1); proc_mc_out(1); + ef sw_output=Font+Report+Temp: proc_report_out(1); fi - draw (0,h)--(0,0)--(w,0)--(w,h)--(0,h)--(w,0) wpcs thickness_frame; - fi - %----------------------------------------------------------------------------------------- - endchar; - clearit; - %----------------------------------------------------------------------------------------- - if sw_output=Font+Info+Temp: proc_info_out(1,1); - ef sw_output=Font+Mcode+Temp: proc_mc_out(1); - ef sw_output=Font+Info+Mcode+Temp: proc_info_out(1,1); proc_mc_out(1); - ef sw_output=Font+Report+Temp: proc_report_out(1); + %----------------------------------------------------------------------------------------- + ef sw_output=Info: proc_info_out(1,0); + ef sw_output=Info+Table: proc_info_out(2,0); + ef sw_output=Info+Temp: proc_info_out(1,1); + ef sw_output=Info+Mcode: proc_info_out(1,2); + ef sw_output=Mcode: proc_mc_out(0); + ef sw_output=Mcode+Temp: proc_mc_out(1); + ef sw_output=Mfont: proc_mf_out(1); + ef sw_output=Report: proc_report_out(0); + ef sw_output=Report+Temp: proc_report_out(1); + ef sw_output=MOL2k: proc_mol_out(1); + ef sw_output=MOL3k: proc_mol_out(2); + ef sw_output=Info+Mcode+Temp: proc_mc_out(1); proc_info_out(1,1); fi - %----------------------------------------------------------------------------------------- - ef sw_output=Info: proc_info_out(1,0); - ef sw_output=Info+Table: proc_info_out(2,0); - ef sw_output=Info+Temp: proc_info_out(1,1); - ef sw_output=Mcode: proc_mc_out(0); - ef sw_output=Mcode+Temp: proc_mc_out(1); - ef sw_output=Mfont: proc_mf_out(0); - ef sw_output=Report: proc_report_out(0); - ef sw_output=Report+Temp: proc_report_out(1); - ef sw_output=MOL2k: proc_mol_out(1); - ef sw_output=MOL3k: proc_mol_out(2); - ef sw_output=Info+Mcode+Temp: proc_mc_out(1); proc_info_out(1,1); - fi - %----------------------------------------------------------------------------------------------- - %% message "* parts_cnt (0)="& decimal(parts_cnt) &" "& decimal(parts_usr-parts_usr_start); - %% message "* parts_int (0)="& decimal(parts_int) &" "& decimal(parts_int-parts_int_start); - %----------------------------------------------------------------------------------------------- + %--------------------------------------------------------------------------------------------- + %% message "* parts_cnt (0)="& decimal(parts_cnt) &" "& decimal(parts_usr-parts_usr_start); + %% message "* parts_int (0)="& decimal(parts_int) &" "& decimal(parts_int-parts_int_start); + %--------------------------------------------------------------------------------------------- fi - %----------------------------------------------------------------------------------------------- + %--------------------------------------------------------------------------------------------- restore_par(parameter_list); if proc_end=1: scantokens("bye"); fi endgroup; enddef; %------------------------------------------------------------------------------------------------- -def pickup_data_unit(expr t,v)= +def pickup_data_unit(expr t,v,f)= begingroup - save unit_cnt,f_end,semicol_cnt,cond,n_var; - f_end:=unit_cnt:=semicol_cnt:=cond:=at_semicol[0]:=inf_num:=0; - if t="n": n_var:=scantokens(v); fi + save unit_cnt,f_end,semicol_cnt,f_match,var_n,info_s,tag_a,var_a; + string tag_a[],var_a[],info_s; + f_end:=unit_cnt:=semicol_cnt:=f_match:=inf_num:=0; + if t="n": var_n:=scantokens(v); fi forever: temps:=readfrom file_name_input; if temps=EOF: f_EOF:=1; fi @@ -388,11 +397,10 @@ def pickup_data_unit(expr t,v)= if subc(1,temps)="%": ef (subc(1,temps)="+")and(subc(2,temps)<>"-"): unit_cnt:=unit_cnt+1; - if v="*": cond:=1; - ef t="n": if unit_cnt=n_var: cond:=1; fi - else: if v=scantokens("inf_"&t): cond:=1; fi + if v="*": f_match:=1; + ef t="n": if unit_cnt=var_n: f_match:=1; fi fi - if cond=1: + if f_match=1: forever: temps:=readfrom file_name_input; if temps=EOF: f_EOF:=1; fi @@ -400,12 +408,15 @@ def pickup_data_unit(expr t,v)= exitif subc(1,temps)="+"; if subc(1,temps)<>"%": mc_row:=mc_row+1; - n_fw:=scan_char(" ",temps,1,1); - mc_indent[mc_row]:=n_fw-1; - mc[mc_row]:=substring (n_fw-1,length(temps)) of temps; + fw_n:=scan_char(" ",temps,1,1); + mc_indent[mc_row]:=fw_n-1; + mc[mc_row]:=substring (fw_n-1,length(temps)) of temps; mc:=mc&mc[mc_row]; fi endfor + for i=1 upto inf_num: + if known scantokens("inf_"&tag_a[i]): scantokens("inf_"&tag_a[i]):=var_a[i]; fi + endfor f_end:=1; else: forever: @@ -416,21 +427,21 @@ def pickup_data_unit(expr t,v)= endfor fi else: - semicol_cnt:=count_char(";",temps); + semicol_cnt:=count_semicol(temps); inf_num:=semicol_cnt+1; for i=1 upto inf_num: - if i<=semicol_cnt: info[i]:=substring (at_semicol[i-1],at_semicol[i]-1) of temps; - else: info[i]:=substring (at_semicol[semicol_cnt],length(temps)) of temps; + if i<=semicol_cnt: info_s:=substring (at_semicol[i-1],at_semicol[i]-1) of temps; + else: info_s:=substring (at_semicol[semicol_cnt],length(temps)) of temps; fi - at_colon:=scan_char(":",info[i],0,1); - s_tag:=substring (0,at_colon-1) of info[i]; - s_var:=substring (at_colon,length(info[i])) of info[i]; - if known scantokens("inf_"&s_tag): scantokens("inf_"&s_tag):=s_var; fi + at_colon:=scan_char(":",info_s,0,1); + tag_a[i]:=substring (0,at_colon-1) of info_s; + var_a[i]:=substring (at_colon,length(info_s)) of info_s; + if t=tag_a[i]: if v=var_a[i]: f_match:=1; fi fi endfor fi exitif f_end=1; endfor - if f_close=1: closefrom file_name_input; fi + if f=1: closefrom file_name_input; fi endgroup; enddef; %-------------------------------------------------------------------------------------------------- @@ -445,13 +456,6 @@ vardef scan_char(expr c,s,d,n)= fi n_s enddef; -%-------------------------------------------------------------------------------------------------- -vardef count_char(expr c,s)= - save nS; - nS:=0; - for i=1 upto length(s): if subc(i,s)=c: nS:=nS+1; at_semicol[nS]:=i; fi endfor - nS -enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def set_def_MC= save /,//,/*,*/,**,*/*,~,^,',`,<,>,:,=,\,\\,*\,\*,*\*,@,@$,$,&,&$,#,##,{,},|,||,_,inside_def_MC; @@ -890,7 +894,7 @@ def MC(text TXT)= pair temp_p; %----------------------------------------------------------------------------------------------- if sw_numbering>=1: ratio_atom_bond:=0.25; fi - if (sw_expand=1)or(sw_output=MOL2k)or(sw_output=MOL3k): + if (sw_expand=1)or(scan_bit(sw_output,MOL2k))or(scan_bit(sw_output,MOL3k)): expand_set; crR:=1; else: crR:=-ratio_chain_ring; fi cntA:=cntB:=cntC:=cnt_group:=0; strD[0]:="C"; str_cnt:=2000; @@ -927,77 +931,86 @@ def MC(text TXT)= endfor if blen>max_blength: blen:=max_blength; proc_size_setup; proc_skeleton(0); proc_scaling; fi fi - %-draw atom------------------------------------------------------------------------------------- - if sw_numbering=0: for i=1 upto cntA: draw_atom(i); endfor fi - %-draw add to atom------------------------------------------------------------------------------ + %----------------------------------------------------------------------------------------------- for i=1 upto cntA: if addA[i]<>0: - temp_c:=char(addA[i]); nA:=angX[i]+add_rot[i]; nC:=nA mod 90; + temp_c:=char(addA[i]); if temp_c="+": chargeA[i]:=1; elseif temp_c="-": chargeA[i]:=-1; else: chargeA[i]:=0; fi - if numS[i]=0: nB:=.5atom_wd; - else: nB:=.85wdA[i]+iif(nC<45,sind(nC),cosd(nC))*.5wdA[i]; - fi - temp_p:=sfrt(posA[i]-(.35atom_wd,.35atom_wd),nB,nA); - draw_char(temp_c,temp_p,atom_wd,bond_pen_wd*ratio_char_bond,0); else: chargeA[i]:=0; fi endfor - %-draw bond------------------------------------------------------------------------------------- - for i=1 upto cntB: if lineB[i]<si_ : draw_bond(i); fi endfor - for i=1 upto cntB: if lineB[i]>=si_: draw_bond(i); fi endfor - %-atom numbering-------------------------------------------------------------------------------- - if scan_bit(sw_numbering,Atom): + %=============================================================================================== + if scan_bit(sw_output,Font): + %-draw atom----------------------------------------------------------------------------------- + if sw_numbering=0: for i=1 upto cntA: draw_atom(i); endfor fi + %-draw add to atom---------------------------------------------------------------------------- for i=1 upto cntA: - if (i>=numbering_start)and(i<=numbering_end): - if scan_bit(sw_numbering,Brock): nA:=i-numbering_start+1; - elseif scan_bit(sw_numbering,Inverse): - nA:=iif(numbering_end<cntA,numbering_end-i+1,cntA-i+1); - else: nA:=i; + if addA[i]<>0: + nA:=angX[i]+add_rot[i]; nC:=nA mod 90; + if numS[i]=0: nB:=.5atom_wd; + else: nB:=.85wdA[i]+iif(nC<45,sind(nC),cosd(nC))*.5wdA[i]; fi - erase fill unitsquare xscaled (.8atom_wd*length(decimal(nA))) - yscaled atom_wd shifted (posA[i]-(.5atom_wd,.5atom_wd)); - defaultsize:=atom_wd; defaultscale:=1; - puts(posA[i]-(.5atom_wd,.5atom_wd))(decimal(nA)); + temp_p:=sfrt(posA[i]-(.35atom_wd,.35atom_wd),nB,nA); + draw_char(temp_c,temp_p,atom_wd,bond_pen_wd*ratio_char_bond,0); fi endfor - fi - %-bond numbering-------------------------------------------------------------------------------- - if scan_bit(sw_numbering,Bond): - for i=1 upto cntB: - if (i>=numbering_start)and(i<=numbering_end): - if scan_bit(sw_numbering,Brock): nB:=i-numbering_start+1; - elseif scan_bit(sw_numbering,Inverse): - nB:=iif(numbering_end<cntB,numbering_end-i+1,cntB-i+1); - else: nB:=i; + %-draw bond----------------------------------------------------------------------------------- + for i=1 upto cntB: if lineB[i]<si_ : draw_bond(i); fi endfor + 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): + if scan_bit(sw_numbering,Brock): nA:=i-numbering_start+1; + elseif scan_bit(sw_numbering,Inverse): + nA:=iif(numbering_end<cntA,numbering_end-i+1,cntA-i+1); + else: nA:=i; + fi + erase fill unitsquare xscaled (.8atom_wd*length(decimal(nA))) + yscaled atom_wd shifted (posA[i]-(.5atom_wd,.5atom_wd)); + defaultsize:=atom_wd; defaultscale:=1; + puts(posA[i]-(.5atom_wd,.5atom_wd))(decimal(nA)); fi - erase fill unitsquare yscaled atom_wd xscaled (.8atom_wd*length(decimal(nB))) - shifted (.5[posA[sB[i]],posA[eB[i]]]-(.5atom_wd,.5atom_wd)); - defaultsize:=atom_wd; defaultscale:=1; - puts(0.5[posA[sB[i]],posA[eB[i]]]-(.5atom_wd,.5atom_wd))(decimal(nB)); - fi - endfor - fi - %----------------------------------------------------------------------------------------------- - if xpart(mposition)>1: sftX:=xpart(mposition)-minX; - else: sftX:=margin_lr-minX+(font_wd-mol_wd-2margin_lr)*xpart(mposition); - fi - if ypart(mposition)>1: sftY:=ypart(mposition)-minY; - else: sftY:=margin_tb-minY+(font_ht-mol_ht-2margin_tb)*ypart(mposition); - fi - cntM:=cntM+1; - posM[0][cntM]:=(sftX,sftY); - posM[1][cntM]:=(minX+sftX,minY+sftY); - posM[2][cntM]:=(maxX+sftX,maxY+sftY); - wdM[cntM]:=mol_wd; - htM[cntM]:=mol_ht; - mol_stru[cntM]:=currentpicture; - clearit; - endgroup; - if sw_output>=1: proc_calc(0); fi - if cntC>=1: + endfor + fi + %-bond numbering------------------------------------------------------------------------------ + if scan_bit(sw_numbering,Bond): + for i=1 upto cntB: + if (i>=numbering_start)and(i<=numbering_end): + if scan_bit(sw_numbering,Brock): nB:=i-numbering_start+1; + elseif scan_bit(sw_numbering,Inverse): + nB:=iif(numbering_end<cntB,numbering_end-i+1,cntB-i+1); + else: nB:=i; + fi + erase fill unitsquare yscaled atom_wd xscaled (.8atom_wd*length(decimal(nB))) + shifted (.5[posA[sB[i]],posA[eB[i]]]-(.5atom_wd,.5atom_wd)); + defaultsize:=atom_wd; defaultscale:=1; + puts(0.5[posA[sB[i]],posA[eB[i]]]-(.5atom_wd,.5atom_wd))(decimal(nB)); + fi + endfor + fi + %--------------------------------------------------------------------------------------------- + if xpart(mposition)>1: sftX:=xpart(mposition)-minX; + else: sftX:=margin_lr-minX+(font_wd-mol_wd-2margin_lr)*xpart(mposition); + fi + if ypart(mposition)>1: sftY:=ypart(mposition)-minY; + else: sftY:=margin_tb-minY+(font_ht-mol_ht-2margin_tb)*ypart(mposition); + fi + cntM:=cntM+1; + posM[0][cntM]:=(sftX,sftY); + posM[1][cntM]:=(minX+sftX,minY+sftY); + posM[2][cntM]:=(maxX+sftX,maxY+sftY); + wdM[cntM]:=mol_wd; + htM[cntM]:=mol_ht; + mol_stru[cntM]:=currentpicture; + clearit; + if cntC>=1: for i=1 upto cntA: if colorA[i]<>0: colorA[i]:=0; fi endfor for i=1 upto cntB: if colorB[i]<>0: colorB[i]:=0; fi endfor + fi fi + if sw_output>=Info: proc_check_structure(0); fi + endgroup; enddef; %------------------------------------------------------------------------------------------------- def add_group= @@ -1591,7 +1604,7 @@ vardef erase_space(expr TXT)= temp_s enddef; %================================================================================================= -def proc_calc(expr n)= +def proc_check_structure(expr n)= begingroup save knownA,tmp_wtp; num_MW:=num_MI:=cen_MW:=cen_MI:=tbl_atom_max:=warning_cnt:=hideH_cnt:=0; @@ -1669,6 +1682,7 @@ enddef; def proc_info_out(expr n,f)= message "["&decimal(char_num)&"]:"&inf_EN; if f=1: file_name_output:="temp-info.aux"; + ef f=2: file_name_output:=jobname&"-data.aux"; else: file_name_output:=jobname&"-info.aux"; fi %-------------------------------------------------------------------------------------- @@ -1705,7 +1719,11 @@ def proc_info_out(expr n,f)= ef tag[i]="MC": & inf_MC fi endfor ; - if f=1: printf EOF; fi + if f=1: printf EOF; + ef f=2: printf "+"; + for i=1 upto mc_row: printf (substring(0,mc_indent[i]) of blank_str)&mc[i]; endfor + printf "+-----------------------------------------------------------------------------"; + fi enddef; %================================================================================================= def proc_report_out(expr f)= @@ -1823,12 +1841,10 @@ enddef; def proc_mf_out(expr f)= message "["&decimal(char_num)&"]:"&inf_EN; file_name_output:=jobname&"-mf.aux"; - printf "beginfont(" - for i=1 upto inf_num: &ditto&info[i]&ditto&"," endfor ; - for i=1 upto mc_row: - printf ditto&": " if i=mc_row: &mc[i]&ditto&")"; else: &mc[i]&ditto&","; fi - endfor - printf "if check(mc)=0: MC(scantokens(mc)) fi"; + printf "beginfont()"; + printf "MC("; + for i=1 upto mc_row: printf mc[i]; endfor + printf ")"; printf "endfont"; if f=1: printf "%-------------------------------------------------------------------------"; fi enddef; @@ -1952,9 +1968,11 @@ R6:='("R6"); R7:='("{R^7^}"); R8:='("{R^8^}"); R9:='("{R^9^}"); R10:='("R^10^"); 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,60,H); xNH:='(N,/H); xNH2:='(N,/H,60,H); xNO2:='(N,//O,60~dm,O); xNO:='(N,!~dm,O); -xSO2H:='(S,//O,!,O,!,H); xSO3H:='(S,//O^35,//O^-35,!,O,!,H); xCOO:='(//O,!,O); -xOH:='(O,!,H); xCHO:='(//O,!,H); xCOOH:='(//O,!,O,!,H); xCN:='(!~tm,N); xSH:='(S,!,H); +xCH3:='(/H,/H^60,/H^-60); xNH:='(N,/H); xNH2:='(N,/H^60,/H^-60); xNO2:='(N,//O^60,//O^-60); +xOH:='(O,/H); xNO:='(N,//O); 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); +!xOH:='(!,xOH); !xCHO:='(!,xCHO); !xCOOH:='(!,xCOOH); !xCH3:='(!,xCH3); !xCN:='(!,xCN); +!xNH2:='(!,xNH2); !xNO2:='(!,xNO2); !xSH:='(!,xSH); %================================================================================================= init_par(parameter_list); %------------------------------------------------------------------------------------------------- @@ -1963,9 +1981,8 @@ init_par(parameter_list); %------------------------------------------------------------------------------------------------- def expand_set= CH3:=xCH3; NH:=xNH; NH2:=xNH2; NO:=xNO; NO2:=xNO2; OH:=xOH; CHO:=xCHO; COOH:=xCOOH; CN:=xCN; - SH:=xSH; SO2H:=xSO2H; SO3H:=xSO3H; COO[-1]:=xCOO; - !CH3:='(!,CH3); !OH:='(!,OH); !NH2:='(!,NH2); !CHO:='(!,CHO); !COOH:='(!,COOH); !CN:='(!,CN); - !SH:='(!,SH); !NO2:='(!,NO2); + SH:=xSH; SO2H:=xSO2H; SO3H:=xSO3H; !SH:=!xSH; + !CH3:=!xCH3; !OH:=!xOH; !NH2:=!xNH2; !CHO:=!xCHO; !COOH:=!xCOOH; !CN:=!xCN; !NO2:=!xNO2; enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% vardef check(expr s)= @@ -2080,25 +2097,24 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def query(text s)= begingroup - save temps,file_name,f_mcf,f_line,unit_row,unit_cnt,line_s,unit_row_cnt,mc_row,line_cnt, - semicol_cnt,inf_num,info_s,filter_n,tag_s,var_s,order,min_s,min_n,par_cnt,key_cnt,var_n, - sign_at,sign_n,filter_tag,filter_var,filter_sign,filter_cnt,temp_s, - at_semicol,at_colon,at_equal,at_less,at_greater,at_n; - string line_s[][],sort_s[],par_list[],sort_all[],key_s[],filter_s[],filter_tag[],filter_var[], - temps,file_name_input,info_s,tag_s,var_s,temp_s,min_s; - numeric unit_row_cnt[],at_semicol[],order[],order_tbl[],filter_sign[]; - unit_row:=f_mcf:=mc_row:=line_cnt:=inf_num:=par_cnt:=key_cnt:=filter_cnt:=at_semicol[0]:=0; + save file_name,f_mcf,f_line,unit_row,unit_cnt,line_s,unit_row_cnt,mc_row,line_cnt, + semicol_cnt,info_cnt,info_s,filter_n,order,min_s,min_n,par_cnt,key_cnt,var_n,info_s, + sign_at,sign_n,filter_tag,filter_var,filter_sign,filter_cnt,filter_p,temp_s,par_s, + at_colon,at_equal,at_less,at_greater,at_n,info_cnt; + string line_s[][],sort_s[],par_s[],sort_all[],key_s[],filter_s[],filter_tag[],filter_var[], + info_s[],file_name_input,temp_s,min_s; + numeric unit_row_cnt[],order[],order_tbl[],filter_sign[],filter_p[]; + unit_row:=f_mcf:=mc_row:=line_cnt:=info_cnt:=par_cnt:=key_cnt:=filter_cnt:=0; unit_cnt:=1; - for list=s: par_cnt:=par_cnt+1; par_list[par_cnt]:=list; endfor %------------------------------------------------------------------------------------------------ file_name_input:=default_data_file; file_name_output:=default_temp_file; %------------------------------------------------------------------------------------------------ - for j=1 upto par_cnt: - at_colon:=scan_char(":",par_list[j],0,1); - at_equal:=scan_char("=",par_list[j],0,1); - at_less:=scan_char("<",par_list[j],0,1); - at_greater:=scan_char(">",par_list[j],0,1); + for list=s: + at_colon:=scan_char(":",list,0,1); + at_equal:=scan_char("=",list,0,1); + at_less:=scan_char("<",list,0,1); + at_greater:=scan_char(">",list,0,1); %--------------------------------------------------------------------------------------------- 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; @@ -2108,12 +2124,18 @@ def query(text s)= 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 - tag_s:=substring (0,sign_at-at_n) of par_list[j]; - var_s:=substring (sign_at,length(par_list[j])) of par_list[j]; + tag_s:=substring (0,sign_at-at_n) of list; + var_s:=substring (sign_at,length(list)) of list; %--------------------------------------------------------------------------------------------- if sign_n=0: - if tag_s="i": file_name_input:=var_s; - ef tag_s="o": file_name_output:=var_s; + if tag_s="f": + if scan_char(".",var_s,0,1)=0: file_name_input:=var_s&".mcf"; + else: file_name_input:=var_s; + fi + ef tag_s="o": + if scan_char(".",var_s,0,1)=0: file_name_output:=var_s&".aux"; + else: file_name_output:=var_s; + fi ef tag_s="s": key_cnt:=key_cnt+1; key_s[key_cnt]:=var_s; fi %--------------------------------------------------------------------------------------------- @@ -2121,12 +2143,12 @@ def query(text s)= filter_cnt:=filter_cnt+1; filter_tag[filter_cnt]:=tag_s; filter_sign[filter_cnt]:=sign_n; - if (sign_n>=3)and(is_num(var_s)=1): filter_var[filter_cnt]:=fix_n(var_s); + if (sign_n>=3)and(is_num(var_s)=1): filter_var[filter_cnt]:=fix_num(var_s); else: filter_var[filter_cnt]:=var_s; fi fi endfor - %------------------------------------------------------------------------------------------------ + %----------------------------------------------------------------------------------------------- forever: temps:=readfrom file_name_input; exitif temps=EOF; if subc(1,temps)<>"%": @@ -2136,51 +2158,61 @@ def query(text s)= ef (subc(1,temps)="+")and(subc(2,temps)="-"): unit_row_cnt[unit_cnt]:=unit_row; f_mcf:=unit_row:=0; - if filter_n=1: unit_cnt:=unit_cnt+1; fi - ef (subc(1,temps)<>"+")and(subc(1,temps)<>"%"): - if f_mcf=1: mc_row:=mc_row+1; - else: - semicol_cnt:=count_char(";",temps); - inf_num:=semicol_cnt+1; - filter_n:=1; - %--------------------------------------------------------------------------------------- - for i=1 upto inf_num: - if i<=semicol_cnt: info_s:=substring (at_semicol[i-1],at_semicol[i]-1) of temps; - else: info_s:=substring (at_semicol[semicol_cnt],length(temps)) of temps; + filter_n:=1; + for i=1 upto filter_cnt: filter_p[i]:=0; endfor + for i=1 upto key_cnt: sort_s[i]:=""; endfor + %--------------------------------------------------------------------------------------- + for i=1 upto info_cnt: + at_colon:=scan_char(":",info_s[i],0,1); + tag_s:=substring (0,at_colon-1) of info_s[i]; + var_s:=substring (at_colon,length(info_s[i])) of info_s[i]; + %------------------------------------------------------------------------------------- + for j=1 upto key_cnt: + if key_s[j]=tag_s: + if is_num(var_s)=1: sort_s[j]:=fix_num(var_s); else: sort_s[j]:=var_s; fi fi - at_colon:=scan_char(":",info_s,0,1); - tag_s:=substring (0,at_colon-1) of info_s; - var_s:=substring (at_colon,length(info_s)) of info_s; - %------------------------------------------------------------------------------------- - for j=1 upto key_cnt: - if key_s[j]=tag_s: - if is_num(var_s)=1: sort_s[j]:=fix_n(var_s); else: sort_s[j]:=var_s; fi + endfor + %------------------------------------------------------------------------------------- + for j=1 upto filter_cnt: + if filter_tag[j]=tag_s: + filter_p[j]:=1; + if (filter_sign[j]>=3)and(is_num(var_s)=1): temp_s:=fix_num(var_s); + else: temp_s:=var_s; fi - endfor - %------------------------------------------------------------------------------------- - for j=1 upto filter_cnt: - if filter_tag[j]=tag_s: - if (filter_sign[j]>=3)and(is_num(var_s)=1): temp_s:=fix_n(var_s); - else: temp_s:=var_s; - fi - if filter_sign[j]=1: if not(temp_s= filter_var[j]): filter_n:=0; fi - ef filter_sign[j]=2: if not(temp_s<>filter_var[j]): filter_n:=0; fi - ef filter_sign[j]=3: if not(temp_s< filter_var[j]): filter_n:=0; fi - ef filter_sign[j]=4: if not(temp_s> filter_var[j]): filter_n:=0; fi - ef filter_sign[j]=5: if not(temp_s<=filter_var[j]): filter_n:=0; fi - ef filter_sign[j]=6: if not(temp_s>=filter_var[j]): filter_n:=0; fi - fi + if filter_sign[j]=1: if not(temp_s= filter_var[j]): filter_n:=0; fi + ef filter_sign[j]=2: if not(temp_s<>filter_var[j]): filter_n:=0; fi + ef filter_sign[j]=3: if not(temp_s< filter_var[j]): filter_n:=0; fi + ef filter_sign[j]=4: if not(temp_s> filter_var[j]): filter_n:=0; fi + ef filter_sign[j]=5: if not(temp_s<=filter_var[j]): filter_n:=0; fi + ef filter_sign[j]=6: if not(temp_s>=filter_var[j]): filter_n:=0; fi fi - endfor + fi endfor - %------------------------------------------------------------------------------------- - sort_all[unit_cnt]:=""; - for j=1 upto key_cnt: - if j=key_cnt: sort_all[unit_cnt]:=sort_all[unit_cnt]&sort_s[j]; - else: sort_all[unit_cnt]:=fix_s(15,sort_s[1]); + endfor + for i=1 upto filter_cnt: if filter_p[i]=0: filter_n:=0; fi endfor + %------------------------------------------------------------------------------------- + sort_all[unit_cnt]:=""; + for j=1 upto key_cnt: + if j=key_cnt: sort_all[unit_cnt]:=sort_all[unit_cnt]&sort_s[j]; + else: sort_all[unit_cnt]:=fix_str(15,sort_s[1]); + fi + endfor + %------------------------------------------------------------------------------------- + info_cnt:=0; + if filter_n=1: unit_cnt:=unit_cnt+1; fi + %------------------------------------------------------------------------------------- + ef (subc(1,temps)<>"+")and(subc(1,temps)<>"%"): + if f_mcf=1: mc_row:=mc_row+1; + else: + semicol_cnt:=count_semicol(temps); + for i=1 upto semicol_cnt+1: + info_cnt:=info_cnt+1; + if i<=semicol_cnt: + info_s[info_cnt]:=substring (at_semicol[i-1],at_semicol[i]-1) of temps; + else: + info_s[info_cnt]:=substring (at_semicol[semicol_cnt],length(temps)) of temps; fi endfor - %------------------------------------------------------------------------------------- fi fi fi @@ -2206,7 +2238,7 @@ def query(text s)= endgroup; enddef; %============================================================================================= -vardef fix_s(expr n,s)= +vardef fix_str(expr n,s)= save temp_s; string temp_s; if length(s)<n: temp_s:=s&substring(0,n-length(s)) of blank_str; @@ -2215,7 +2247,7 @@ vardef fix_s(expr n,s)= temp_s enddef; %--------------------------------------------------------------------------------------------- -vardef fix_n(expr s)= +vardef fix_num(expr s)= save temp_s,at_dot; string temp_s; temp_s:=s; @@ -2235,4 +2267,11 @@ vardef is_num(expr s)= endfor numeric_n enddef; +%-------------------------------------------------------------------------------------------------- +vardef count_semicol(expr s)= + save nS; + nS:=at_semicol[0]:=0; + for i=1 upto length(s): if subc(i,s)=";": nS:=nS+1; at_semicol[nS]:=i; fi endfor + nS +enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |