11 //______________________________________________________________________
14 // Sub-class of TMacro, overriding Exec to unload the previous verison
15 // and cleanup after the execution.
19 RMacro::RMacro() : TMacro() {}
21 RMacro::RMacro(const RMacro& m) : TMacro(m) {}
23 RMacro::RMacro(const char* name) :
30 char *dot = (char*)strrchr(name, '.');
31 char *slash = (char*)strrchr(name, '/');
33 if (slash) fName = slash + 1;
39 /**************************************************************************/
43 void RMacro::Exec(const char* params)
45 if(Reve::CheckMacro(fTitle.Data()))
46 G__unloadfile(fTitle.Data());
48 // Copy from TMacro::Exec. Difference is that the file is really placed
50 TString fname = "/tmp/";
52 //the current implementation uses a file in the current directory.
53 //should be replaced by a direct execution from memory by CINT
57 //disable a possible call to gROOT->Reset from the executed script
58 gROOT->SetExecutingMacro(kTRUE);
59 //execute script in /tmp
60 TString exec = ".x " + fname;
62 if (p == "") p = fParams;
64 exec += "(" + p + ")";
66 gROOT->ProcessLine(exec, &exit);
68 gROOT->SetExecutingMacro(kFALSE);
69 //delete the temporary file
70 gSystem->Unlink(fname);
75 // In case an exception was thrown (which i do not know how to detect
76 // the execution of next macros does not succeed.
77 // However strange this might seem, this solves the problem.
78 TTimer::SingleShot(100, "Reve::RMacro", this, "ResetRoot()");
81 #include <TApplication.h>
83 void RMacro::ResetRoot()
85 // printf ("RMacro::ResetRoot doing 'gROOT->Reset()'.\n");
86 gROOT->GetApplication()->ProcessLine("gROOT->Reset()");