gROOT->ProcessLine

Dear experts,

I want to use gROOT->ProcessLine in [1] but I got this error message [2], do you know what is wrong? I was using it successfully in root version<6.

[2]

error: use of undeclared identifier 'func' func(); ^
[1]

[code]void plot(){

gROOT->ProcessLine(".L func.C");
func();

}

func.C
void func(){
gROOT->SetStyle(“Plain”);
gStyle->SetPalette(1);

}[/code]

Hi,

the change consists in the fact that the ROOT6 interpreter is based on a real compiler and does not parse line by line the code it’s fed with.
In this case

void plot(){
gROOT->ProcessLine(".L func.C");
func();
}

The interpreter has no means to know what symbol is “func”, in fact it would be available only at runtime only after parsing func.C.
There are of course ways to reformulate your code, for example you could add a ‘#include “func.C”’ to the file where you implement the “plot” function.

Cheers,
Danilo

Dear Danilo,

thank you, it worked.

Regards