Re: executing one macro from another

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Mar 27 2000 - 11:19:21 MEST


Hi Rutger,
The best solution is to use gROOT->Loadmacro("file.C") and then invoke
one or more functions of file.C
Always use named macros when you use more than one macro. You will avoid
the usual scoping problems.
In your case, I suggest the following sequence:
  gROOT->LoadMacro("macroa.C"); //contains functions funca1, funca2, etc
  gROOT->LoadMacro("macrob.C"); //contains functions funcb1, funcb2,etc
  in funca1 or funca2, you can now call funcb1, funcb2, etc (normal C++)

Rene Brun


Rutger van der Eijk wrote:
> 
> Hi,
> 
> I want to execute one macro from another macro. In this way a 'top macro'
> can configure the job. But I can't get it to work.
> 
> Example:
> 
> --------- macro topMacro.C
> {
> 
>    gInterpreter->ExecuteMacro("subMacro1.C");
> 
> }
> --------- subMacro1.C
> {
>  // do something
> }
> 
> If I do (within RINT):
> 
> .x topMacro.C
> 
> I get something like:
> 
> Error: file subMacro1.C can not open
> 
> I tried various things in topMacro.C:
> 
> 1) gInterpreter->ExecuteMacro("subMacro1.C");
> 2) gInterpreter->Processline(".x subMacro1.C");
> 
> In understand this somehow means a recursive use of interpreter. But I
> think it must be possible somehow (I think I remember the Alice ppl
> do things like that.) What is the right procedure to get this to work?
> 
> Thanks,
> 
> Rutger van der Eijk



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:22 MET