(let ((gpscript '("set format y \"%5.0f\""
"set format y2 \"%5.0f\""
"#set yrange [9800:10150]"
"set y2range [100:1800]"
(format nil "set xtics ~A" (floor (/ numdatapoints 20)))
"set xtics nomirror"
"set ytics nomirror"
"set y2tics nomirror"
"set grid y"
"set title \"Mongoose V RTEMS Interrupt Distributions\""
"set xlabel \"Sample Number\""
"set ylabel \"Int Interval(us)\""
"set y2label \"Int Duration(us)\""
"set key box"
"plot 'intdistro-cooked.txt' using 1:3 axes x1y1 title \"Interval\" with linespoints, \\"
"'intdistro-cooked.txt' using 1:2 axes x1y2 title \"Duration\" with linespoints pt 3"
"quit")))
(with-open-stream (gpstr (sys:open-pipe "/usr/bin/gnuplot -geometry 1200x768 -persist" :direction :io :buffered nil))
(mapc #'(lambda (s)
(format gpstr "~A~%" (eval s))) gpscript) ))
The gnuplot datafile was generated prior to this code snippet, as was
the value in numdatapoints. As you can see, this is a fairly
uninspired way of arranging things, but it should serve well enough.
The problem is the (eval) within mapc down at the bottom. It works
well enough for the string literals, but because eval uses the "null
lexical environment", numdatapoints- which is a variable defined by a
surrounding let- could not be found.
I nosed around (apply) and (funcall), but they don't seem to be doing
the right kinds of things- what I think I really want is an
"eval-like" function which uses the local lexical environment.
I added '(declare (special numdatapoints))' just after the let where
numdatapoints was defined, which seems to have made (eval) happy. Is
this reasonable- or at least not too horrible way to approach this
problem?
Thanks,
Greg Menke
Why do you need to use EVAL at all? Why don't you use the value of
NUMDATAPOINTS when you're building the gpscript list in the first place:
(let ((gpscript `("set format y \"%5.0f\""
...
,(format nil "set xtics ~A" (floor (/ numdatapoints 20)))
...)))
(with-open-stream (gpstr ...)
(mapc #'(lambda (s)
(format gpstr "~A~%" s)) gpscript)))
--
Barry Margolin, bar...@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
I don't. I forgot about backquote and ,
Thanks,
Gregm
Backquote is just a shorthand. Even without it you could write:
(list "set format y \"%5.0f\""
(format nil "set xtics ~A" ...))
Of course! I knew I was missing something obvious.
Thanks,
Gregm
> I'm consolidating some Lisp & shell script stuff we use to feed logic
> analyzer data to gnuplot, moving everything into Lisp. Particularly,
In case you are interested, `cllib', which is part of CLOCC (Common Lisp
Open Code Collection), includes a gnuplot interface:
Paolo
--
EncyCMUCLopedia * Extensive collection of CMU Common Lisp documentation
http://web.mclink.it/amoroso/ency/README
[http://cvs2.cons.org:8000/cmucl/doc/EncyCMUCLopedia/]
>
> > I'm consolidating some Lisp & shell script stuff we use to feed logic
> > analyzer data to gnuplot, moving everything into Lisp. Particularly,
>
> In case you are interested, `cllib', which is part of CLOCC (Common Lisp
> Open Code Collection), includes a gnuplot interface:
>
> http://clocc.sourceforge.net
I looked at it, but didn't need anything that fancy. If there were
any sort of variability in how I generate the graphs I'd probably use
it.
Gregm
I have tried installing this with _zero_ success thus far. There seem
to be a number of actions that need to be taken to get it installed
that are not documented in the documentation. (Notably, how is it
supposed to locate $(TOP)/bin/run-lisp?)
The library looks to have interesting stuff in it, but installing it
is a challenge...
--
(concatenate 'string "cbbrowne" "@sympatico.ca")
http://www.ntlug.org/~cbbrowne/spiritual.html
Rules of the Evil Overlord #217. "If I'm wearing the key to the hero's
shackles around my neck and his former girlfriend now volunteers to
become my mistress and we are all alone in my bedchamber on my bed and
she offers me a goblet of wine, I will politely decline the offer."
<http://www.eviloverlord.com/>