I am running Gnuplot in the confines of VBA and it works surprisingly well. I am able to produce an entire book of about one hundred graphs using GNUPLOT and Word VBA. (With Excel graphs, I could get maybe about four)
There is one small problem - STDERR disappears, or is not being created, when run under VBA. No diagnostics.
Given the following small GNUPLOT script,
set key bmargin left horizontal Right noreverse enhanced autotitle box lt black linewidth 1.000 dashtype solid
set samples 800, 800
set title "Simple Plots"
set title font ",20" norotate
DEBUG_TERM_HTIC = 119
DEBUG_TERM_VTIC = 119
plot [-30:20] sin(x*20)*atan(x)
my VBA code writes it to a temporary file and attempts to run it. VBA generates
"C:\temp\Gnuplot\bin\gnuplot.exe" C:\Users\VVKOZLOV\AppData\Local\Temp\gnuA5E0.txt 2>"C:\Users\VVKOZLOV\AppData\Local\Temp\gnuA5E2.err"
Then runs it with the Windows Shell, invoked like so:
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
then
wsh.Run x, 0, True ' x contains the generated GNUPLOT expression
GNUPLOT executes flawlessly.
In the GNUPLOT expression, the first item is the location of the GNUPLOT program, which on my system happens to be "C:\temp\Gnuplot\bin\gnuplot.exe"
. The second file is the temporary generated in the official Microsoft location C:\Users\VVKOZLOV\AppData\Local\Temp\gnuA5E0.txt
. Last is the location of STDERR, 2>"C:\Users\VVKOZLOV\AppData\Local\Temp\gnuA5E2.err"
where the 2> thing indicates that this is STDERR, not the normal output STDOUT.
Now suppose I introduce a deliberate error into the GNUPLOT source, I would expect an error file written containing something like
scooby doo where are you?
^
"C:\Users\VVKozlov\AppData\Local\Temp\gnuEC55.txt", line 4: invalid command
When executed with the usual CMD.EXE outside of VBA, the STDERR file is created as expected.
When executed in the confines of VBA using the Windows Shell, no STDERR file is created.
How could I get this STDERR file to be produced under VBA?