Re: [ROOT] create and read global variables

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed May 16 2001 - 12:46:49 MEST


Hi Christian,

A small example with two macros macro1.C and macro2.C.
To run do:
root > .L macro1.C
root > macro1()
root > .L macro2.C
root > macro2()

//file macro1.C
TList list;
void macro1()
{
   TH1F *h = new TH1F("h","h",100,-3,3);
   h.FillRandom("gaus");
   list.Add(h);
}

//file macro2.C
void macro2()
{
   list.ls();
}

Rene Brun

Christian Doerr wrote:
> 
> Hello everybody,
> 
> I just started using root, so maybe the solution to my problem is a
> quite trivial - I want to create a  class object (class TMyList) in a
> first macro  named TEvent.C  as global variable gList and then use/read
> it again from a second macro:
> 
> root[1] .L TEvent.C
> root[2] InitList();
> root[3] .g
> 
> ....
> TEvent.C        294 0x868e360  TMyList gList , size=8
> ....
> 
> root[4]
> 
> How can I access gList again from another macro?
> 
> Thanks!
> 
> Christian Doerr
> 
> -----------------------------------------------------------------------
> Christian Doerr                         cdoerr@physi.uni-heidelberg.de
> Physikalisches Institut                 www.christiandoerr.de
> Universitaet Heidelberg
> -----------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Fri Jun 08 2001 - 11:51:25 MEST