×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    287

    TBuf to TInt conversion

    hi,

    i tried to convert TBuf to Tint but The Below code are not working


    Code:
    _LIT(mn,"100");
    TBuf<100> at;
    at.Copy(mn);
    TInt numIndex;
    TLex iLex(at);
     iLex.Val(numIndex);

  2. #2
    Registered User
    Join Date
    Jun 2008
    Location
    India
    Posts
    1,048

    Re: TBuf to TInt conversion

    Quote Originally Posted by arun09 View Post
    hi,

    i tried to convert TBuf to Tint but The Below code are not working


    Code:
    _LIT(mn,"100");
    TBuf<100> at;
    at.Copy(mn);
    TInt numIndex;
    TLex iLex(at);
     iLex.Val(numIndex);
    Ok do like this its perfect.

    http://wiki.forum.nokia.com/index.ph...Buf_to_TInt%3F

  3. #3
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    287

    Re: TBuf to TInt conversion

    Quote Originally Posted by sumit.rathi View Post
    ok i tried to this but the output value of numIndex is -2045913644

  4. #4
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,081

    Re: TBuf to TInt conversion

    Quote Originally Posted by arun09 View Post
    hi,

    i tried to convert TBuf to Tint but The Below code are not working


    Code:
    _LIT(mn,"100");
    TBuf<100> at;
    at.Copy(mn);
    TInt numIndex;
    TLex iLex(at);
     iLex.Val(numIndex);

    i tried your code, it works very ok, it wrote the value 100, stored inside numIndex

    what value does this code returns in your case?

  5. #5
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: TBuf to TInt conversion

    Code looks fine to me. Not working means what happens?? what is final value of numIndex ???

  6. #6
    Registered User
    Join Date
    Jun 2008
    Location
    India
    Posts
    1,048

    Re: TBuf to TInt conversion

    Quote Originally Posted by arun09 View Post
    ok i tried to this but the output value of numIndex is -2045913644
    Try again properly Arun. As other guys are saying that its working.

  7. #7
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    287

    Re: TBuf to TInt conversion

    Quote Originally Posted by savaj View Post
    Code looks fine to me. Not working means what happens?? what is final value of numIndex ???
    my problem are given below
    Code:
    Tint num=100
    LogPrintfL(KLogFile,"num %d ",num);
    the value of num ie 100 are successfully writting a File

    then

    Code:
    _LIT(mn,"100");
    TBuf<100> at;
    at.Copy(mn);
     TInt numIndex;
     TLex iLex(at);
     iLex.Val(numIndex);
    LogPrintfL(KLogFile,"num %d ",numIndex);
    by using the above code the value written in file is not same as actual value
    i m getting below value in file
    Code:
    num -2045913644

  8. #8
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,081

    Re: TBuf to TInt conversion

    ok try one thing, do not write this value in a file just show it in a popup or some alert, then see what vakue it is showing up.For e.g:

    TBuf<20>buffer;
    buffer.AppendNum(numIndex);
    CAknInformationNote*note = new(ELeave)CAknInformationNote;
    note->ExecuteLD(buffer);

    so now see what value it pop ups

  9. #9
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    287

    Re: TBuf to TInt conversion

    Quote Originally Posted by vineet.jain View Post
    ok try one thing, do not write this value in a file just show it in a popup or some alert, then see what vakue it is showing up.For e.g:

    TBuf<20>buffer;
    buffer.AppendNum(numIndex);
    CAknInformationNote*note = new(ELeave)CAknInformationNote;
    note->ExecuteLD(buffer);

    so now see what value it pop ups
    ok thanks

    now my problem is
    Code:
    _LIT(mn,"9999999999");
    			TBuf<256> at;
    			at.Copy(mn);
    			  TInt numIndex;
    			   	 TLex iLex(at);
    			   	 iLex.Val(numIndex);
    			   TInt ar;
    			   ar=numIndex;
    			  // TInt64 ac(ar);
    			   	LogPrintfL(KLogFile,"number %d ",  ar);
    the bove value not write the file
    but
    the given value are ie 1234567891 are successfilly written
    Code:
    _LIT(mn,"1234567891");
    			TBuf<256> at;
    			at.Copy(mn);
    			  TInt numIndex;
    			   	 TLex iLex(at);
    			   	 iLex.Val(numIndex);
    			   TInt ar;
    			   ar=numIndex;
    			  // TInt64 ac(ar);
    			   	LogPrintfL(KLogFile,"number %d ",  ar);

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: TBuf to TInt conversion

    Check if 9 999 999 999 happens to be larger than 2 147 483 647 (the largest number which can be represented by a 32-bit signed integer). Then repeat the same check with 1 234 567 891.

Similar Threads

  1. Problem creating FEP-aware text control
    By mike.b in forum Symbian User Interface
    Replies: 7
    Last Post: 2010-11-22, 10:17
  2. data type conversion from TInt?
    By sunny_pirate in forum Symbian
    Replies: 13
    Last Post: 2009-03-17, 11:43
  3. internal heap limit reached
    By shilpav in forum Symbian User Interface
    Replies: 1
    Last Post: 2004-10-14, 09:43
  4. TBuf to TInt?
    By Nokia_Archive in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2002-06-02, 05:11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×