|
From: Ethan M. <merritt@u.washington.edu> - 2006-03-03 22:35:01
|
On Friday 03 March 2006 10:44 am, Petr Mikulik wrote:
> > Can we discuss this some more first?
> > Or at least let me try out the patch first?
> > I'm not 100% convinced it will always work, even on linux.
>
> It is enclosed, please try it. I think it must work everywhere where
> fopen() is implemented. (And gnuplot without fopen() cannot live.)
I think this function could use some more polishing to remove
rough edges.
Here's one scenario which could cause much confusion.
The new function does not use the same path to look for
files that is used by the actual plot command:
gnuplot> !printenv GNUPLOT_LIB
../demo
gnuplot> print (fileexist("../demo/silver.dat")) ? "OK" : "File not
found"
OK
gnuplot> print (fileexist("silver.dat")) ? "OK" : "File not found"
File not found
gnuplot> plot "silver.dat"
[plots normally even though fileexist didn't find it]
Here's another. The new function does not recognize pipes
gnuplot> DATAFILE = "< head -40 ../demo/silver.dat"
gnuplot> plot DATAFILE
gnuplot> print (fileexist(DATAFILE)) ? "OK" : "File not found"
File not found
I agree that no one is likely to type such a sequence of commands
from the command line. But I take it that the purpose of the new
command would be to place in an automated script, so that the
script can handle non-existence of a data file cleanly. But then
it is much harder for the caller to understand why these example
do not work as expected. For example, the user might think it
was a clever idea to use GNUPLOT_LIB to point to any one of
several data directories:
setenv GNUPLOT_LIB /jan2006/data
gnuplot script.gp
setenv GNUPLOT_LIB /feb2006/data
gnuplot script.gp
Where script.gp also tries to be clever, but in an incompatible way:
# Loop over data files and plot each one we find
if (!defined(plotno)) plotno = 1
file = sprintf("datafile.%d",plotno)
if (!fileexist(file)) exit
plot file
plotno = plotno+1
reread
The pipe failure could also arise from a plausible attempt to
automate a sequence of plots that involve pre-processing the
data.
--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle WA
|