Parsing array item

Login to reply to this topic.
Fri, 2007-08-03 10:22
Joined: 2007-07-24
Forum posts: 24

I have array iDetailsArray, of type CDesCArray.

//Fetching data from i th location from Array
 
  TDesC aData= (*iDetailsArray)[i]; 

// suppose i got data as "ABC 41A  -1000"
// OR "ABCDE  +500"

// Now i want to parse this data & collect
//only  "ABC 41A" OR "ABCDE" & remove -1000
// OR +500

   TLex lexer(aData);
   TChar chr;
   lexer.SkipSpaceAndMark();
  
   while (!lexer.Eos())
   {
      chr = lexer.Get();

      if ( chr != '+'||chr !='-' )
      {

      }
}

What i have to do in "IF LOOP" to take data in any TDesC veriable ?

Thanks


Fri, 2007-08-03 10:50
Joined: 2006-04-19
Forum posts: 155
Re: Parsing array item

Try this

TBuf<20> tempBuf;
TInt pos = aData.Find( _L("+") );

if(pos == KErrNone)
{
tempBuf = aData.Left(pos);
}

See TDesC in SDK

BR
Isha


"To the question of your life , you are the only Answer. To the problems of your life,you are the only Solution".

Fri, 2007-08-03 13:27
Joined: 2007-07-24
Forum posts: 24
Re: Parsing array item

Thanks Isha for your suggestion.

I tried that but it's not going in "IF LOOP" Here is my code......

TBuf<20> tempBuf;
TDesC aData=(*iDetailsArray)[3]; 
TInt pos = aData.Find( _L("#") );

if(pos == KErrNone)
{
//        tempBuf = aData.Left(pos);
        CEikonEnv::InfoWinL(_L("Test"),_L("In if loop"));
}

Thanks

Fri, 2007-08-03 14:10
Joined: 2007-07-24
Forum posts: 24
Re: Parsing array item

got soln for this...........

i directly used

(*iDetailsArray)[3].Mid(1);

Anyway, thanks for ypur help

  • Login to reply to this topic.