Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > gnuplot parameter interchange

Reply
Thread Tools

gnuplot parameter interchange

 
 
Bernhard Hidding
Guest
Posts: n/a
 
      06-25-2004
Hello,
my c++ programm produces a variable number of ASCII files with variable file
names. These are to be plotted in with gnuplot. I use

system("gnuplot -persist my_gnuplot_script.gpl");

to open gnuplot, and "my_gnuplot_script.gpl" contains a list of files to be
plotted (e.g. plot "array13.dat", "array87.dat",...). However, each time the
program runs, different files are to be plotted, so I have to change the
file names in my gnuplot script manually each time. How can I hand over some
parameters to gnuplot? Or would it be the easiest way to modify my .gpl
script by my c++ program? If so, how do I do that?
Thanks in advance,
Bernhard Hidding

-------------------------
SuSE 9.1, g++ compiler


 
Reply With Quote
 
 
 
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      06-25-2004
Bernhard Hidding wrote:
>
> Hello,
> my c++ programm produces a variable number of ASCII files with variable file
> names. These are to be plotted in with gnuplot. I use
>
> system("gnuplot -persist my_gnuplot_script.gpl");
>
> to open gnuplot, and "my_gnuplot_script.gpl" contains a list of files to be
> plotted (e.g. plot "array13.dat", "array87.dat",...). However, each time the
> program runs, different files are to be plotted, so I have to change the
> file names in my gnuplot script manually each time. How can I hand over some
> parameters to gnuplot? Or would it be the easiest way to modify my .gpl
> script by my c++ program? If so, how do I do that?


What you pass to system() is a string. Of course you can use a string
variable also. And thus you have every freedom you want to come
up with that string.

#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{
std::string CommandLine;
std::string FileName;

CommandLine = "gnuplot -persist ";

cout << "Which file to plot?\n";
cin >> FileName;

CommandLine += FileName;

cout << "Executing command: " << CommandLine << endl;
system( CommandLine.c_str() );
}

--
Karl Heinz Buchegger
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Bernhard Hidding
Guest
Posts: n/a
 
      06-25-2004
Thank you,
but that is not quite what I intend to do. Maybe I did not make myself clear
enough.
In this case it is not enough to be able to chose between different gnuplot
script files, but to generate a script file on the fly. Each time my program
runs, a different script file would be needed, because each time new ASCII
files with different names are being created which shall be plotted. My c++
program contains all the data that the gnuplot script file would need to
know. So, is it the easiest way to let my c++ program create the gnuplot
script file and write it to disk, and call it after that? Or is there a
convenient way to pass variables over to gnuplot?

Bernhard


 
Reply With Quote
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      06-25-2004
Bernhard Hidding wrote:
>
> Thank you,
> but that is not quite what I intend to do. Maybe I did not make myself clear
> enough.
> In this case it is not enough to be able to chose between different gnuplot
> script files, but to generate a script file on the fly.


open script file
write commands as text to script file
close script file

use system() to execute script file

> Each time my program
> runs, a different script file would be needed, because each time new ASCII
> files with different names are being created which shall be plotted. My c++
> program contains all the data that the gnuplot script file would need to
> know. So, is it the easiest way to let my c++ program create the gnuplot
> script file and write it to disk, and call it after that? Or is there a
> convenient way to pass variables over to gnuplot?


C++ knows nothing about gnuplot. There may be some way to control gnuplot
through some interprocess mechanism.

The simplest thing is .... see above

--
Karl Heinz Buchegger
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Type interchange Edward Rutherford C Programming 35 01-25-2012 09:02 PM
Vista DVD 32/64 bit coa interchange? =?Utf-8?B?TGVu?= Windows 64bit 2 02-19-2007 07:20 PM
Concrete example of data interchange using xml document and schema WideBoy XML 0 01-04-2006 10:59 AM
Interchange web host maz NZ Computing 0 04-06-2005 10:07 AM
Interchange 2 nibbles of byte Sreejith K C++ 4 11-14-2003 09:17 AM



Advertisments