Calling macro within macro

Hi,

I am running an unnamed script

[code]
{
gROOT->Reset();

gROOT->ProcessLine(".x drPlots.C");
gROOT->ProcessLine(".x etconePlots.C");

}[/code]

both drPlots and etconePlots draws and saves histograms. The drPlot and etconePlot both have an internal counter that counts number of canvases openend, and saves the plots like this:

 cannum++;
 sprintf(canvasname,"c1_n%d",cannum);
 c=(TCanvas*)gROOT->FindObject(canvasname);
 c->Print("plot.png");

Problem is that I would like to print and close the canvases in drPlot.C before I open etconePlot.C.

Is there any way of doing this?

Thanks!

Maiken

[quote]Problem is that I would like to print and close the canvases in drPlot.C before I open etconePlot.C. [/quote]I am not sure what you mean (it seems that just adding “delete c;” to your code snippet would do). What did you try and how did it fail?

Cheers,
Philippe

The canvases open with names c1, c1_n2, c1_n3 etc. Each file drPlot and etconePlot wants to draw and save their respective canvases. But, as e.g. drPlot last canvas is called c1_n3, the first canvas in etconePlot will be c1_n4. I would like it to start again at c1, due to my automatic way of counting canvases and saving them, and I do not want the two files to be dependent on each other.

That is why I would like to finish with drPlot (drawing and saving) before I open etconePlot.

Is that clear?

Thanks!
Maiken

[quote]due to my automatic way of counting canvases and saving them[/quote]Humm … a priori you could simply reset your counter at the start of both macros … or at the end … or you could use a different counter variable … or (depending what your code look like) you could make make both macro name instead of unnamed …

[quote]to finish with drPlot [/quote]I must be missing something essential :slight_smile:, it would seem that this would already be the case … drPlot.C is fully executed before starting the next one …

Cheers,
Philippe

Hmm, maybe it is not a problem after all…

I was getting confused since the canvases that open persist in calling themselves c1_n, but I understand now, that the name I give to the canvas is the one I can use to save them etc., so no problem! :blush:

Thanks!

Maiken