Good idea Devon.

If you change the random number appended to the file name to a time stamp (say 
up to ms) it might be clearer (also most recent plots are clear), in the same 
way Screenshot on Mac works.

Best, Rob

> On 12 Nov 2020, at 6:52 am, Devon McCormick <[email protected]> wrote:
> 
> I have often been annoyed by the behavior of plot when I try to plot
> something but have previously plotted something so the 2nd plot fails with
> this message:
>   Unable to write to file: ...plot.pdf
>   If the file is open in Adobe, close the file and try again.
> 
> I changed this behavior by inserting this code into "pdf_write" in
> "jzplot.ijs" and "pdfdraw.ijs":
> wroteFile=. 1
> if. _1 -: dat flwrite file do.
>  file=. (":?1e3) (([ ,~ ] {.~ '.' i:~ ]) , ] }.~ '.' i:~ ]) file
>  wroteFile=. 0
> end.
> if. -.wroteFile do.
> ...
> end.
> 
> immediately preceding and encompassing the statement block starting "while.
> _1 -: dat flwrite file do." in both jzplot and pdfdraw; I also made a
> similar change for "OutputFile" in the function "write" in "publish.ijs".
> 
> This changes the name of "plot.pdf" to "'plot',(":?1e3),'.pdf'" if the
> initial write attempt fails but this name change is local to the writing
> fns so I don't know what side-effects this has.
> 
> It looks like the name "~temp/plot.pdf" is assigned to the global
> "PDF_DEFFILE" in jzplot.  The only place I see this global used is inside
> "pdf_getparms" which is used in "pdf_show" and "pdf_get" and these two
> function names are assigned to the globals "pd_pdf" and "pd_pdfr" in
> jzplot.  I don't see any uses of these names other than this assignment.
> 
> In any case, it would be nice to incorporate this into the J code base.  If
> not, I suppose I can continue to manually update the modules whenever I
> upgrade.  Maybe  I will eventually encounter an unwanted side-effect.
> Right now it looks like this change might clutter up my ~temp area with
> random PDF files but I can live with that.
> 
> -- 
> 
> Devon McCormick, CFA
> 
> Quantitative Consultant
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to