# Passing a filename as an argument to a macro

Hi all,

I want to pass the name of an existing root file as an argument to a macro. I am trying something like,

root “doExtract.C(/mnt/aheplabpce/vj/Linux/BXsPhi/jae/rootfiles/file1.root)”

(actually, the previous command is inside a script, but at the moment I am testing it from the command line)

where doExtract.C looks like,

doExtract(char* filename){
TFile *_file0 = TFile::Open(filename);
gROOT->ProcessLine(".L extract.C+");
extract a(ntp2);
a.Loop(0,0,0,0);
gROOT->ProcessLine(".q");
}

Obviously, something is not right, since I keep getting syntax errors. I have tried using filename with and without " " in the Tfile::Open command.

Any ideas

Vivek

Hi Vivek,

root 'doExtract.C("/mnt/aheplabpce/vj/Linux/BXsPhi/jae/rootfiles/file1.root")'
should work.

Axel.

hi axel,

thanks. that worked.

vivek