module gnuplot; algebraic operator family; global '(!*plot_pipe); switch plot_pipe; fluid '(plotranges!* plotfunctions!* plotpipe!* plotstyle!* plotoptions!*); global '(plotcommand plotdata plotdata2 plotheader); share plotdata,plotdata2,plotcommand,plotheader; % Some systems might prefer that the first six characters are different % in the following file names. if null plotdata then plotdata:= "/tmp/plotdata"; if null plotdata2 then plotdata2:= "/tmp/plotdata2"; if null plotcommand then plotcommand:="gnuplot"; plotheader := ""; if atom errorset('(load pipes),nil,nil) then <> else !*plot_pipe := t; symbolic procedure plotreset(); if !*plot_pipe and plotpipe!* then <>; symbolic operator plotreset; % Create .. as the infix operator if not yet done. newtok '( (!. !.) !*interval!*); precedence .., or; algebraic operator ..; put('!*interval!*,'PRTCH,'! !.!.! ); symbolic procedure adomainp u; numberp u or (pairp u and idp car u and get(car u,'dname)) or eqcar(u,'minus) and adomainp cadr u; symbolic procedure revalnuminterval(u,num); % Evaluate u as interval; numeric bounds required if num=T. begin scalar l; if not eqcar(u,'!*interval!*) then typerr(u,"interval"); l:={reval cadr u,reval caddr u}; if null num or(adomainp car l and adomainp cadr l)then return l; typerr(u,"numeric interval"); end; symbolic procedure PlotOpenDisplay(); begin if null plotpipe!* then if not !*plot_pipe then plotpipe!* := open(plotdata,'output) else <>; if atom plotheader then <> else if eqcar(plotheader,'list) then for each x in cdr plotheader do <> else typerr(plotheader,"gnuplot header"); end; symbolic procedure plotshow(); if !*plot_pipe and plotpipe!* then << channelflush plotpipe!*; >> else < in order to continue REDUCE "; system bldmsg("%w %w",plotcommand,plotdata);>> else begin scalar w1,w2; % Added for systems without bldmsg. w1 := explode plotcommand; w2 := explode plotdata; w1 := append(reverse cdr reverse w1,'! . cdr w2); w1 := compress w1; prin2 "About to execute: "; prin2t w1; prin2t "enter in order to continue REDUCE "; system w1 end>>; % This uses !*lower to lower case on output. This is not part of % Standard Lisp and so will not work in many systems. symbolic procedure plotprin2 u; <> where v=wrs plotpipe!*,!*lower=t; symbolic procedure plotterpri(); <> where v=wrs plotpipe!*; fluid '(plotprinitms!*); symbolic procedure plotprinexpr u; begin scalar plotprinitms!*,!*lower,v; !*lower:=t; v := wrs plotpipe!*; plotprinitms!* := 0; if eqcar(u,'file) then <> else errorset(list('plotprinexpr1,mkquote u,nil),nil,nil); wrs v; end; symbolic procedure plotprinexpr1(u,oldop); begin scalar op; if plotprinitms!* > 5 then <>; if atom u then <> else if eqcar(u,'!:rd!:) then plotprinexpr1 (if atom cdr u then cdr u else cadr u * (10.0 ** cddr u),nil) else if (op:=car u) memq '(plus times difference quotient expt) then plotprinexpr2(cdr u,get(car u,'PRTCH), oldop and not (op memq(oldop memq '(difference plus times quotient expt))) ,op) else if op='MINUS then <> else if get(car u,'!:RD!:) then <> else typerr(u," expression for printing") end; symbolic procedure plotprinexpr2(u,sep,br,op); <>; if br then prin2 ") " >>; symbolic procedure ploteval u; <>; put('family,'plotdo,'plotfamily); symbolic procedure ploteval0 option; begin scalar l,r; if option memq '( arrow noarrow contour nocontour autoscale noautoscale border noborder clip noclip polar nopolar grid nogrid key nokey label nolabel logscale nologscale surface nosurface tics time notime zeroaxis nozeroaxis hidden3d nohidden3d) then <> else if eqcar(option,'list) then <