×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    May 2007
    Location
    Slovakia
    Posts
    12

    Angry TLex returns wrong value

    Hi, i have in buffer some hex value and i want show it in decimal representation, here is the code:

    TBuf8<16> tmp;
    tmp.AppendNumFixedWidthUC(x4, EHex, 2); // 5B
    tmp.AppendNumFixedWidthUC(x3, EHex, 2); // 07
    tmp.AppendNumFixedWidthUC(x2, EHex, 2); // 15
    tmp.AppendNumFixedWidthUC(x1, EHex, 2); // BA

    // when i draw 'tmp' to screen, it shows "5B0715BA", thats ok

    // now convert it to decimal
    TLex8 lextmp (tmp);
    TUint32 value;
    lextmp.Val(value, EDecimal);

    // when i draw 'value' to screen using AppendNum, it shows only "5", but correct value is 1527190970.

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

    Re: TLex returns wrong value

    try converting the hex string bit by bit to decimal, by running a for loop till the length of the tmp descriptor.Append the converted value to a buffer bit by bit.

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

    Re: TLex returns wrong value

    Use EHex to parse hexadecimal digits, not EDecimal.

    Something like:
    TLex8 lextmp (tmp);
    TUint32 value;
    lextmp.Val(value, EHex );

  4. #4
    Registered User
    Join Date
    May 2007
    Location
    Slovakia
    Posts
    12

    Re: TLex returns wrong value

    Wow, this works!

    But i dont understand when i use EDecimal, it shows only "5".

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,748

    Re: TLex returns wrong value

    Because "B" is not a decimal digit. Thus TLex stops parsing after "5".

Similar Threads

  1. ExampleClientEngine ...
    By GeKI in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2005-12-16, 07:12
  2. How to Prompt the user for IAP selection only if the wrong IAP is currently selected
    By kaiser_20 in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-10-26, 15:19
  3. Replies: 0
    Last Post: 2005-02-16, 14:20
  4. whats wrong with this code?
    By Rx-lee in forum Symbian
    Replies: 4
    Last Post: 2004-03-25, 10:50

Posting Permissions

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