Hi Dmitri,
I've fixed the case of negative numbers. Now
e->GetValue("TLegoDisplay.Phi",0);
will return -417.
However, a workaround exists, do:
e->GetValue("TLegoDisplay.Phi","0");
and this will return the string "-417", now just do atoi and its ok:
phi = atoi(e->GetValue("TLegoDisplay.Phi","0"));
Also to get floats you have to use the above method since there is
no other way to get floats out of TEnv. Example:
minpi: -3.141589
double minpi = atof(e->GetValue("minpi","0"));
In the new version you can override the needed methods to customize
TEnv to read .rc files from specific locations (and skip the $ROOTSYS
one).
Cheers, Fons.
Dmitri Litvintsev wrote:
>
> Sorry, I wasn't specific enough - I don't have trouble saving values.
> I have problem with reading values:
>
> root [0] TEnv* e = new TEnv(".evdrc");
> root [1] e->Print()
> TCotDisplay.TrackColor: 1 [User]
> TCotDisplay.WindowWidth: 536 [User]
> TCotDisplay.WindowHeight: 649 [User]
> TCotDisplay.WindowXPosition: 26 [User]
> TCotDisplay.WindowYPosition: 25 [User]
> TCotDisplay.ViewPadColor: 0 [User]
> TLegoDisplay.WindowWidth: 536 [User]
> TLegoDisplay.WindowHeight: 649 [User]
> TLegoDisplay.WindowXPosition: 973 [User]
> TLegoDisplay.WindowYPosition: 193 [User]
> TLegoDisplay.ViewPadColor: 1 [User]
> TLegoDisplay.Phi: -417 [User]
> TLegoDisplay.Theta: 38 [User]
> TLegoDisplay.Psi: 0 [User]
> root [2] Int_t phi = e->GetValue("TLegoDisplay.Phi",0);
> root [3] cout << phi << endl;
> 0
> root [4] e->SetValue("TLegoDisplay.Phi","417");
> root [5] e->Save()
> root [6] phi = e->GetValue("TLegoDisplay.Phi",0);
> root [7] cout << phi << endl;
> 417
>
> as you see positive value of phi has been read out in contrast to negative
>
> show me where I'm wrong here
>
> >
> > Cheers, Fons.
> >
> >
> >
> > Dmitri Litvintsev wrote:
> > >
> > > Dear Rooters,
> > >
> > > I've been developing ROOT application and want read/save
> > > application specific resources from/to a file which is not
> > > located in $(ROOTSYS) and called differently.
> > >
> > > e.g.
> > >
> > > default file for all users to fetch at start up:
> > > ${OUR_PROJECT}/${MY_APPLICATION}/.myenvrc
> > >
> > > if user modified and saved some applicaion specific resources
> > > it should go to his ${HOME}/.myenvrc
> > >
> > > I see that there is a class TEnv which probably does this for the
> > > ROOT.
> > >
> > > I thought of using TEnv class.
> > >
> > > And overide a couple of relevant methods. The trouble is
> > > that:
> > > Save()
> > > SaveLevel()
> > > SetValue()
> > >
> > > are not virtual. May I ask to make all methods of this class
> > > virtual?
> > >
> > > regards,
> > > Dmitri Litvintsev
> > >
> > > /----------------------------------------------------------\
> > > | Tel: (630) 840 5005 |
> > > | FAX: (630) 840 2968 |
> > > | office: 169-E CDF Trailers |
> > > | E-mail: litvinse@fnal.gov |
> > > \----------------------------------------------------------/
> >
> > --
> > Org: CERN, European Laboratory for Particle Physics.
> > Mail: 1211 Geneve 23, Switzerland
> > E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248
> > WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7677910
> >
--
Org: CERN, European Laboratory for Particle Physics.
Mail: 1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248
WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7677910
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:22 MET