From maechler@stat.math.ethz.ch  Thu Jul  6 16:37:16 2000
From: maechler@stat.math.ethz.ch (maechler@stat.math.ethz.ch)
Date: Thu, 6 Jul 2000 17:37:16 +0200 (MET DST)
Subject: [Rd] Re: [R] R 1.1.0 dev.print() & dev.copy2eps -- bug{let} (PR#596)
Message-ID: <200007061537.RAA02134@pubhealth.ku.dk>

>>>>> "StEgl" == Stephen Eglen <stephen@cogsci.ed.ac.uk> writes:

    StEgl> Hi, I just upgraded to 1.1.0 from 1.0.1 this morning on my OSF/1
    StEgl> machine.  I now have problems with the following code:

    StEgl> %E /tmp 43% R --vanilla
    StEgl> Version 1.1.0  (June 15, 2000)
    StEgl> ...

    >> test2 <- function ()
    {
    plot(runif(30))
    ofile <- "/tmp/newfile.ps"
    dev.print(file = ofile)
    }

    StEgl> + + + + + > > test2()
    StEgl> Error in device(...) : Object "ofile" not found


    StEgl> However, if I just write the filename directly into the call to
    StEgl> dev.print() rather than using a variable name, it works okay:


    >> test1 <- function ()
    {
     plot(runif(30))
     dev.print(file = "/tmp/newfile.ps")
    }

    StEgl> + + + + > > test1()
    StEgl> X11 
    StEgl> 2 

    StEgl> I just checked, and test1() works fine on R-1.0.1 
			       -------
you mean  test2();  test1() works on both, right?!

    StEgl> - what am I doing wrong?
nothing, "of course".
You found a bug, and hence I'm CC'ing to R-bugs.

Maybe, dev.print() is not what you should  have been using in the first place,
but rather dev.copy() directly which will probably solve your problem.

NOTE:  dev.print() has been extensively re-worked (for 1.1.0) in order to
       be "smart", e.g.,. to send the current plot to the printer by default
       depending on getOption("printer") and other things, and to allow
       other uses.  Hence, it works on the call and uses eval() ...

It seems is must become even smarter (or less tricky and more robust)...
       
BTW, the same applies to the new  dev.copy2eps() function which falls in
the same pit in its trickyness of using eval(...) :

  > tst3 <- function(outfile) { dev.copy2eps(file = outfile) }
  > tst3("/tmp/my2.eps")
  Error in device(...) : Object "outfile" not found

Martin

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] Re: [R] R 1.1.0 dev.print() & dev.copy2eps -- bug{let} (PR#596)
maechler@stat.math.ethz.ch