Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#312 set error 'stderr_file'

open
nobody
None
5
2013-02-10
2011-12-21
No

A very convenient way to control gnuplot from C under windows is
using a pipe:

FILE *pipe;
if ((pipe = _popen("gnulot.exe", "wt") != NULL) {
fprintf("plot x\n");
_pclose(pipe);
}

However the output of gnuplot to stderr can not retrieved that way

A solution could be a new gnuplot command

set error 'my_stderr_file'

which redirects stderr to 'my_stderr_file'

A very simple implementatio could be:

tables.h
add
S_ERROR,
to set_id

tables.c
add
{ "err$or", S_ERROR },
to set_tbl[]

set.c
add
case S_ERROR:
{
char * testfile = NULL;
c_token++;
if (END_OF_COMMAND) {
fprintf(stderr, "no file specified\n");
} else {
testfile = try_to_get_string();
}
if (testfile) {
gp_expand_tilde(&testfile);
fprintf(stderr, "redirect stderr to %s\n", testfile);
freopen(testfile, "w", stderr);
} else {
fprintf(stderr, "set error: file missing\n");
}
}
break;
to switch(lookup_table(&set_tbl[0],c_token)) {

A more advanced implementation would clone th logic of "set output 't.gif'"

Wilhelm Braunschober

Discussion