Re: [ROOT] TString

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Mon Dec 02 2002 - 11:47:42 MET


Hi Guiseppe,

 could you try to use a different name for the TString in the if()
statement, like v1? Let me know if that works.

-- Fons


On Mon, 2002-12-02 at 09:11, giuseppe.foggi@libero.it wrote:
> Hi rooters,
>  I have a problem with Append method of TString.
>  So this is a subset of my script:
>  
>  ......................
>  s.ReadLine(metricvalue,kFALSE);
>  TString *v=new TString((Int_t)s.Index(' '));
>  pos=(Int_t)s.Index(' ');
>  v->Append(s.Data(),pos);
>  while(((v->Data())!=fMetric[indd])&&(!metricvalue.eof())) 
>  {
>    delete v;     
>   
>    appfile.write(s.Data(), s.Length());
>    appfile<<'\n';
>    s.ReadLine(metricvalue,kFALSE);
>    pos=(Int_t)s.Index(' ');
>    if (pos>0)
>    {
> 	TString *v=new TString((Int_t)s.Index(' '));
> 	v->Append(s.Data(),pos); //In this point I have the problem!!!!!!
>    }
>    else  TString *v=new TString("XXXX");
> 	     
>  } 
>  
>  .....
>  
>  The instruction v->Append(s.Data(),pos) within the body of "if" gets me
>  a empty TString or a TString with random character. 
>  Can somebody tell me why???
>  
>  There are some other method to copy a subset of character of a TString
>  to another TString?
>  
>  I tried with
>  
>  TString s("giuseppe foggi")
>  TString *p= new TString(s,s.Index(' '))
>  
>  so I get the same result!
>  
>  Cheers.
>  
>  Giuseppe Foggi.
>  
> 
-- 
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 7679480



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:22 MET