strings and macros

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

strings and macros

Dr. Johannes Zellner
Hello,

just some thoughts about those nifty strings and macros:

1. A limitation to 80 characters for sprintf really hurts!

2. dynamical macros would be really nice ;-)

    set macros
    pl(x) = sprintf("plot '<extract -n %s' u 2, '<extract -n -f %s' u 3", x, x)
    @pl("myfile.dat")


1. can be implemented easily.
I wouldn't know how to implement 2.

Any comments?

--
Johannes


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
gnuplot-beta mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
Reply | Threaded
Open this post in threaded view
|

Re: strings and macros

Juergen Wieferink
Johannes Zellner wrote:
> 1. A limitation to 80 characters for sprintf really hurts!

Full ACK.  

> 2. dynamical macros would be really nice ;-)
>
>     set macros
>     pl(x) = sprintf("plot '<extract -n %s' u 2, '<extract -n -f %s' u 3",\
>                     x, x)
>     @pl("myfile.dat")

The hardest part in your suggestion would be to construct the
function call.  OTOH, parsing a constant expression is already
implemented.  Thus the hardest part would be to terminate the
expression correctly.

How about:
gnuplot> set macros {expressions}
gnuplot> pl(x) = ...
gnuplot> @@pl("myfile.dat")@@

The "@@" syntax would have the additional advantages of backwards
compatibility and that you could use a general expression, not only
single functions.

...

A few minutes later:
Arrgh!  At the time string_expand() is called, the input line has not
yet been tokenized.

Is there any possibility to tokenize and parse a string not on the
input line?


Juergen





-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
gnuplot-beta mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
Reply | Threaded
Open this post in threaded view
|

Re: strings and macros

Dave Denholm
Juergen Wieferink <[hidden email]> writes:

> Johannes Zellner wrote:
>> 1. A limitation to 80 characters for sprintf really hurts!
>
> Full ACK.  
>
>> 2. dynamical macros would be really nice ;-)
>>
>>     set macros
>>     pl(x) = sprintf("plot '<extract -n %s' u 2, '<extract -n -f %s' u 3",\
>>                     x, x)
>>     @pl("myfile.dat")
>

This particular case can probably be handled using 'call'.

> The hardest part in your suggestion would be to construct the
> function call.  OTOH, parsing a constant expression is already
> implemented.  Thus the hardest part would be to terminate the
> expression correctly.
>
> How about:
> gnuplot> set macros {expressions}
> gnuplot> pl(x) = ...
> gnuplot> @@pl("myfile.dat")@@
>
> The "@@" syntax would have the additional advantages of backwards
> compatibility and that you could use a general expression, not only
> single functions.
>

I've suggested 'eval string-expr'  in the past, to be like sh, perl, etc.


>
> A few minutes later:
> Arrgh!  At the time string_expand() is called, the input line has not
> yet been tokenized.
>
> Is there any possibility to tokenize and parse a string not on the
> input line?
>

I think replot is implemented by building up a new input line and
retokenising.


dd
--
Dave Denholm              <[hidden email]>       http://www.esmertec.com


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
gnuplot-beta mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
Reply | Threaded
Open this post in threaded view
|

Re: strings and macros

Ethan Merritt
In reply to this post by Juergen Wieferink
On Tuesday 05 July 2005 12:07 pm, Juergen Wieferink wrote:
> Johannes Zellner wrote:
> > 1. A limitation to 80 characters for sprintf really hurts!
>
> Full ACK.

OK, OK.  I've coded it up.  It's ugly but it works.
I'll try to clean it up a bit before adding to cvs.


> > 2. dynamical macros would be really nice ;-)

Petr and I had this discussion a while back.
I don't see a good way to do it, for exactly the reason you
pointed out - the macro expansion happens before the line has
been tokenized, so we can't use any of our nice tools to check
for function names or evaluate expressions.

--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
gnuplot-beta mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta