|
From: Ethan M. <merritt@u.washington.edu> - 2009-02-03 23:21:38
|
On Tuesday 03 February 2009 14:39:43 Petr Mikulik wrote:
> > Gnuplot's strstrt() function is just a wrapper for the C library routine strstr().
> > In C you could do:
> >
> > char *piece = "/some/long/path/name";
> > char *end;
> >
> > while (end = strstr( piece, "/" ))
> > do {piece = end+1;}
> >
> > Unfortunately, gnuplot doesn't support while/do so I think you are out of luck.
>
> We can add new function strstrtrev("piece", "/") that would return the last
> occurence of the substring.
>
> Would it be useful to have function for handling file names
> strfileparts('/home/me/bla.dat',n)
> which would return path (for n=1), name (n=2) and extension (n=3)?
These sound very specialized. Why do we need such file-oriented string
operations, that even the standard C library does not support?
I think I'd rather go ahead and add support for a 'while' statement.
It would be limited to a single line, just as the current 'if' statement,
but it should be possible to do.
> That would be quite handy especially in the "plot for" loop.
Could you give an example showing why this would be useful?
--
Ethan A Merritt
|