diff options
Diffstat (limited to 'Master/texmf-dist/scripts/ketcindy/ketlib/ketcindyliboutr.cs')
-rw-r--r-- | Master/texmf-dist/scripts/ketcindy/ketlib/ketcindyliboutr.cs | 228 |
1 files changed, 70 insertions, 158 deletions
diff --git a/Master/texmf-dist/scripts/ketcindy/ketlib/ketcindyliboutr.cs b/Master/texmf-dist/scripts/ketcindy/ketlib/ketcindyliboutr.cs index 946743bed6f..354cedc324e 100644 --- a/Master/texmf-dist/scripts/ketcindy/ketlib/ketcindyliboutr.cs +++ b/Master/texmf-dist/scripts/ketcindy/ketlib/ketcindyliboutr.cs @@ -14,7 +14,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/> // -println("ketcindylibout(20181218 loaded"); +println("ketcindylibout(20190127 loaded"); //help:start(); @@ -783,6 +783,7 @@ CalcbyR(name,path,cmd,optionorg):=( strL=tmp_7; dig=5; tmp=cmd_(length(cmd)-1); //181130from + if(!isstring(tmp),tmp=text(tmp)); //190109 if(indexof(tmp,"=")+indexof(tmp,"::")>0, cat="Y"; , @@ -1132,7 +1133,8 @@ Rfun(name,fun,argL,optionorg):=( cmdL=concat(cmdL,[ nm+"="+fun,argL, ]); - options=concat(options,["Wait=2"]); +// options=concat(options,["Wait=2"]); + options=concat(options,["Wait=2","Cat=y"]); //190109 CalcbyR(nm,cmdL,options); if(ErrFlag==0, if(disp==1, // 15.11.24 @@ -1179,10 +1181,6 @@ Readcsv(pathorg,file,optionorg):=( options=remove(options,[#]); ); ); -// if(tmp=="W", // removed:17.02.19 -// waiting=parse(tmp2); -// options=remove(options,[#]); -// ); if(tmp=="S", sep=tmp2; options=remove(options,[#]); @@ -1285,19 +1283,35 @@ Readcsv(pathorg,file,optionorg):=( ); ); ); -// New readcsv (181125) +// New readcsv [181125] Readcsv(file):=Readcsv(Dirwork,file); -Readcsv(path,file):=( +Readcsv(path,file):=Readcsv(path,file,[]); +Readcsv(path,file,options):=( //help:Readcsv("ex.csv"); //help:Readcsv(directory,"ex.csv"); -//help:Readcsv(options=["Head=yes","Sep=-999","Flat=no","Use=R"]); - regional(dt); +//help:Readcsv(options=["Head=no"]); + regional(dt,eqL,head,from,end,tmp); + tmp=Divoptions(options); + eqL=tmp_5; + head="n"; from=1; //190125from + forall(eqL, + tmp=Strsplit(#,"="); + if(Toupper(substring(tmp_1,0,1))=="H", + head=substring(tmp_2,0,1); + ); + ); + if(Toupper(head)=="Y", + from=2; + ); //190125to dt=readfile2str(path,file); dt=tokenize(dt,"/LF/"); + end=length(dt); if(dt_(length(dt))=="", - dt=dt_(1..(length(dt)-1)); + end=end-1; + dt=dt_(from..end); //190125 ); dt=apply(dt,tokenize(#,",")); + if(length(dt)==1, dt=dt_1); //190125 dt; ); ////%Readcsv end//// @@ -1567,7 +1581,7 @@ Boxplot(nm,dataorg,ypos,dy,optionorg):=( tmp=divoptions(options); eqL=tmp_5; strL=tmp_7; - waiting=3; + waiting=10; wrflg=0; forall(eqL, tmp=indexof(#,"="); @@ -1707,7 +1721,7 @@ Boxplot(nm,dataorg,ypos,dy,optionorg):=( out=bp_(6..length(bp)); if(length(out)>0, out=apply(out,[#,ypos]); - Pointdata(name+text(1),out,concat(options,[0,"Size=4"])); + Pointdata(name+text(1),out,concat(options,[0,"Size=2","Inside=white"])); //190125 ); pstr=substring(pstr,0,length(pstr)-1)+"]"; println("generate totally "+name); @@ -1732,7 +1746,7 @@ Histplot(nm,dataorg,optionorg):=( breaks = "breaks="+Dq+"Sturges"+Dq; density=0; relative=0; - waiting=3; + waiting=10; //190125 forall(eqL, tmp=Strsplit(#,"="); tmp1=Toupper(substring(tmp_1,0,1)); @@ -4756,140 +4770,6 @@ Frifun(name,fun,argL,optionorg):=( parse(nm); ); -Mkketcindyjs():=Mkketcindyjs("ketcindylib"); -Mkketcindyjs(Arg):=( - if(isstring(Arg), - Mkketcindyjs(Arg,[]) - , - Mkketcindyjs("ketcindylib",Arg) - ); -); -Mkketcindyjs(libname,options):=( //17.11.18 -//help:Mkketcindyjs(); -//help:Mkketcindyjs(options=["Tex=y","Net=y"]); - regional(texflg,netflg,tmp,tmp1,tmp2,dirfile,dirwork,dirketjs); - dirwork=replace(Dirwork,"\","/"); - tmp=replace(Dircdy,"\","/"); - if(substring(tmp,length(tmp)-1,length(tmp))=="/",//180411from - dirfile=substring(tmp,0,length(tmp)-1); - , - dirfile=tmp; - );//180411to - tmp=replace(Dirlib,"\","/"); - dirketjs=replace(tmp,"ketlib","ketcindyjs");//180411to - texflg="Y"; - netflg="Y"; - forall(options, - tmp1=Toupper(#); - if(indexof(tmp1,"TEX")>0, - tmp=indexof(tmp1,"="); - texflg=Toupper(substring(tmp1,tmp,tmp+1)); - ); - if(indexof(tmp1,"NET")>0, - tmp=indexof(tmp1,"="); - netflg=Toupper(substring(tmp1,tmp,tmp+1)); - ); - ); - if(isexists(dirfile,Fhead+".html"),//180411to - SCEOUTPUT = openfile(Fhead+".r"); - println(SCEOUTPUT,"Looprange<- function(a,b){"); - println(SCEOUTPUT," if (a<=b) return(a:b)"); - println(SCEOUTPUT," return(c())"); - println(SCEOUTPUT,"}"); - println(SCEOUTPUT,"setwd('"+dirketjs+"')"); - println(SCEOUTPUT,"Dtket=readLines('"+libname+".txt')"); - println(SCEOUTPUT,"setwd('"+dirfile+"')");//180411 - println(SCEOUTPUT,"Dtjs=readLines('"+Fhead+".html')"); - println(SCEOUTPUT,"Qt=rawToChar(as.raw(34))"); - println(SCEOUTPUT, - "Dtinit=c(paste('<script id=',Qt,'csinit',Qt,' type=',Qt,'text/x-cindyscript',Qt,'>',sep=''))"); - println(SCEOUTPUT,"Dtinit=c(Dtinit,Dtket,'</script>')"); - println(SCEOUTPUT,"Dthead=c()"); - println(SCEOUTPUT,"for(I in Looprange(1,length(Dtjs))){"); - println(SCEOUTPUT," if(length(grep('<script id=',Dtjs[I],fixed=TRUE))==0){"); - println(SCEOUTPUT," Tmp=Dtjs[I]"); - if(netflg=="N", - println(SCEOUTPUT, - " if(length(grep('link rel=',Tmp,fixed=TRUE))>0){"); - println(SCEOUTPUT, - " Tmp1='file:///"+dirketjs+"/CindyJS.css'");//180411 - println(SCEOUTPUT, - " Tmp=paste(' <link rel=',Qt,'stylesheet',Qt,' href=',Qt,Tmp1,Qt,'>',sep='')"); - println(SCEOUTPUT, - " }"); - println(SCEOUTPUT, - " Tmp1=length(grep('script type=',Tmp,fixed=TRUE))"); - println(SCEOUTPUT, - " Tmp1=Tmp1*length(grep('Cindy.js',Tmp,fixed=TRUE))"); - println(SCEOUTPUT, - " if(Tmp1>0){"); - println(SCEOUTPUT, - " Tmp1='file:///"+dirketjs+"/Cindy.js'");//180411 - println(SCEOUTPUT, - " Tmp=paste(' <script type=',Qt,'text/javascript',Qt,' src=',Qt,Tmp1,Qt,'>',sep='')"); - println(SCEOUTPUT, - " Tmp=paste(Tmp,'</script>',sep='')"); - println(SCEOUTPUT, - " }"); - ); - println(SCEOUTPUT, - " Dthead=c(Dthead,Tmp)"); - println(SCEOUTPUT, - " }else{"); - println(SCEOUTPUT, - " Is=I; break"); - println(SCEOUTPUT, - " }"); - println(SCEOUTPUT, - "}"); - println(SCEOUTPUT,"Dt=c()"); - println(SCEOUTPUT,"for(I in Looprange(Is,length(Dtjs))){"); - println(SCEOUTPUT," Dt=c(Dt,Dtjs[I])"); - println(SCEOUTPUT," if(length(grep('</script>',Dtjs[I],fixed=TRUE))>0){"); - println(SCEOUTPUT," if(length(grep('draw',Dt[1],fixed=TRUE))>0){Dtdraw=Dt}"); - println(SCEOUTPUT," if(length(grep('keytyped',Dt[1],fixed=TRUE))>0){Dtkey=Dt}"); - println(SCEOUTPUT," Dt=c()"); - println(SCEOUTPUT," if(length(grep('<script id=',Dtjs[I+1],fixed=TRUE))==0){"); - println(SCEOUTPUT," Ie=I+1;break"); - println(SCEOUTPUT," }"); - println(SCEOUTPUT," }"); - println(SCEOUTPUT,"}"); - println(SCEOUTPUT,"Dt=c(Dthead,Dtdraw,Dtkey,Dtinit)"); - println(SCEOUTPUT,"for(I in Looprange(Ie,length(Dtjs))){"); - println(SCEOUTPUT, - " if(length(grep('Button',Dtjs[I],fixed=TRUE))>0){"); - println(SCEOUTPUT, - " if(length(grep(paste(Qt,'Figure',sep=''),Dtjs[I],fixed=TRUE))>0){next}"); - println(SCEOUTPUT, - " if(length(grep(paste(Qt,'Exekc',sep=''),Dtjs[I],fixed=TRUE))>0){next}"); - println(SCEOUTPUT, - " if(length(grep(paste(Qt,'Parent',sep=''),Dtjs[I],fixed=TRUE))>0){next}"); - println(SCEOUTPUT, - " if(length(grep(paste(Qt,'KeTJS',sep=''),Dtjs[I],fixed=TRUE))>0){next}"); - println(SCEOUTPUT, - " }"); - println(SCEOUTPUT," Dt=c(Dt,Dtjs[I])"); - if(texflg=="Y", - println(SCEOUTPUT, - " if(length(grep(paste(Qt,'cs*',Qt,sep=''),Dtjs[I],fixed=TRUE))>0){"); - println(SCEOUTPUT, - " Dt=c(Dt,paste(' use: [',Qt,'katex',Qt,'],',sep=''))"); - println(SCEOUTPUT, - " }"); - ); - println(SCEOUTPUT,"}"); - println(SCEOUTPUT,"setwd('"+dirfile+"')");//180411 - println(SCEOUTPUT,"writeLines(Dt,'"+Fhead+"ketcindy.html',sep='\n')"); - println(SCEOUTPUT,"quit()"); - closefile(SCEOUTPUT); - kcR(PathR,Fhead+".r",["m"]); - println(Fhead+"ketcindy.html generated successfully"); - , - drawtext(mouse().xy-[0,1],"use 'write to CindyJS' before that",size->24,color->[1,0,0]); - wait(3000); - ); -); - ///////////////// C function ////////////////// Cformold(strorg):=( @@ -5200,7 +5080,7 @@ kcC(cname):=( ); //181125to println(SCEOUTPUT,"#!/bin/sh"); println(SCEOUTPUT,"cd "+Dq+Dirwork+Dq); - tmp=PathC+" -lm "+cname+".c -o main.out"; //180612 + tmp=PathC+" "+cname+".c -o main.out -lm"; //190123 println(SCEOUTPUT,tmp); println(SCEOUTPUT,"./main.out"); println(SCEOUTPUT,"echo ////>"+rfile); @@ -5632,6 +5512,22 @@ CalcbyC(name,path,cmd,optionorg):=( ); ////%CalcbyC end//// +////%Gccexists start//// +Gccexists():=( //190124 + regional(out); + if(iswindows(), + out=isexists("",PathC); + , + if(indexof(PathC,"/")==0, //190127from + out=isexists("/usr/bin",PathC); + , + out=isexists("",PathC); + ); + ); //190127to + out; +); +////%Gccexists end//// + ////%ExeccmdC start//// ExeccmdC(nm):=ExeccmdC(nm,[],["do"]); //180531 ExeccmdC(nm,options):=ExeccmdC(nm,options,["do"]); @@ -5794,8 +5690,12 @@ SfbdparadataC(nm,fdorg,optionorg,optionshorg):=( name2h="sfbdh2d"+nm; name3h="sfbdh3d"+nm; fname=Fhead+"sfbd"+nm+".txt"; - options=optionorg; - optionsh=select(optionshorg,length(#)>0); //181107 + options=select(optionorg,length(#)>0); //190123from + tmp=Divoptions(options); + if(length(tmp_7)==0,options=append(options,"dr")); + optionsh=select(optionshorg,length(#)>0); + tmp=Divoptions(optionsh); + if(length(tmp_7)==0,optionsh=append(optionsh,"do")); //190123to tmp=Divoptions(options); eqL=tmp_5; reL=tmp_6; @@ -5918,8 +5818,12 @@ CrvsfparadataC(nm,Fk,sfbdorg,fdorg,optionorg,optionshorg):=( name2h="crvsfh2d"+nm; name3h="crvsfh3d"+nm; fname=Fhead+"crvsf"+nm+".txt"; - options=optionorg; - optionsh=select(optionshorg,length(#)>0); //181107 + options=select(optionorg,length(#)>0); //190123from + tmp=Divoptions(options); + if(length(tmp_7)==0,options=append(options,"dr")); + optionsh=select(optionshorg,length(#)>0); + tmp=Divoptions(optionsh); + if(length(tmp_7)==0,optionsh=append(optionsh,"do")); //190123to tmp=Divoptions(options); eqL=tmp_5; reL=tmp_6; @@ -6280,8 +6184,12 @@ WireparadataC(nm,sfbd,fdorg,wr1,wr2,optionorg,optionshorg):=( name3h="wireh3d"+nm; fname=Fhead+"wire"+nm+".txt"; fnameh=replace(fname,".txt","h.txt"); - options=optionorg; - optionsh=select(optionshorg,length(#)>0); //181107 + options=select(optionorg,length(#)>0); //190123from + tmp=Divoptions(options); + if(length(tmp_7)==0,options=append(options,"dr")); + optionsh=select(optionshorg,length(#)>0); + tmp=Divoptions(optionsh); + if(length(tmp_7)==0,optionsh=append(optionsh,"do")); //190123to tmp=Divoptions(options); eqL=tmp_5; reL=tmp_6; @@ -6579,7 +6487,7 @@ SfcutparadataC(nm,cutfunL,sfbd,fd):=(//180505 SfcutparadataC(nm,cutfunL,sfbd,fd,[],["do"]); ); SfcutparadataC(nm,cutfunL,sfbd,fd,options):= - SfcutparadataC(nm,cutfunL,sfbd,fd,options,["nodisp"]); + SfcutparadataC(nm,cutfunL,sfbd,fd,options,[]); SfcutparadataC(nm,cutfunLorg,sfbd,fdorg,optionorg,optionshorg):=( //help:Sfcutparadata("1","2*x+3*y+z=1","sfbd3d",fd,nohiddenoptions,hiddenoptions); regional(funnm,cutfunL,fd,options,optionsh,name2,name3,name2h,name3h, @@ -6632,8 +6540,12 @@ SfcutparadataC(nm,cutfunLorg,sfbd,fdorg,optionorg,optionshorg):=( options=remove(options,[#]); ); ); - options=remove(options,reL); - options=select(options,length(#)>0); + options=select(optionorg,length(#)>0); //190123from + tmp=Divoptions(options); + if(length(tmp_7)==0,options=append(options,"dr")); + optionsh=select(optionshorg,length(#)>0); + tmp=Divoptions(optionsh); + if(length(tmp_7)==0,optionsh=append(optionsh,"do")); //190123to tmp1=select(options, (indexof(#,"=")>0)&(Toupper(substring(#,0,1))=="C")); //181114from if(length(tmp1)>0, |