Get the output from gROOT->ProcessLine()

Hi,

I have a small cxx program that compiles and runs ROOT code.

I would like to be able to retrieve the output generated when I use ProcessLine method inside my compiled program. For example, when I do this, I get “Hello” word through my console.

gROOT->ProcessLine( "cout << \"Hello\" << endl" );

I would like to recover that output in my main program. Doing something like this, or similar:

TString myOutput = gROOT->ProcessLine( "cout << \"Hello\" << endl" );

It is this possible?

Thanks!

You can try something like the code shown below, but there are probably better ways to do it without needing to call gROOT->ProcessLine in your code. Can you be more specific?

root [0] TString myOutput;
root [1] gROOT->ProcessLine("myOutput = \"Hello\";");
root [2] myOutput
(TString &) "Hello"[5]
root [3] 

You could also do something like this:

TString *myOutput = (TString *)gROOT->ProcessLine("new TString(\"Hello\")");
2 Likes

I love this solution! This is a perfect way to access from compiled code entities created by interpreted code…

P

The answer I was looking for is more connected with @bellenot , so that I have myOutput available in the compiled code, but initialised using gROOT->ProcessLine.

Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.