dcsimg
Results 1 to 6 of 6
  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2017
    Posts
    89

    Resolved [RESOLVED] SMS PDU Calculation

    Guyz,
    What is the meaning of it?? I need a strip down of it...:

    Code:
    PDUCodes(i).Length - Val("&H" & Mid(PDUCodes(i), 1, 2)) * 2 - 2) / 2
    PDUCodes(i) is a loooong hex string of SMS PDU. That's for sure... Like:

    Code:
    07915892000000F001000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E
    and the final result should come 42 after this calculation.

    Ref: http://www.developershome.com/sms/cmgsCommand4.asp

    Mshu~

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    39,810

    Re: SMS PDU Calculation

    This part: Mid(PDUCodes(i), 1, 2)
    ...gets the first two characters of PDUCodes(i), so is the same as "07"

    This part: Val("&H" & "07")
    ...gets the numerical value of the Hex value (converted to decimal), so in this case 7.

    The rest is simple maths, so you can probably work all that out yourself.

  3. #3
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,403

    Re: SMS PDU Calculation

    Quote Originally Posted by aq_mishu View Post
    ...
    and the final result should come 42 after this calculation.
    ...
    I tested it and the final result is 42, so the code works.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2017
    Posts
    89

    Re: SMS PDU Calculation

    Quote Originally Posted by si_the_geek View Post

    The rest is simple maths, so you can probably work all that out yourself.
    If i'm not that stupid in maths:

    Code:
    (PDUCodes(i).Length - Val("&H" & Mid(PDUCodes(i), 1, 2)) * 2 - 2) / 2
    for
    Code:
    07915892000000F001000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E
    = 100 chars

    VAL(&H07) = 07

    hence it is: (100 - (7*2-2))/2 = (100 - 12)/2 = 44

    ????????

  5. #5
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,403

    Re: SMS PDU Calculation

    You have your parentheses wrong.
    It isn't (100 - (7*2-2))/2 = (100 - 12)/2 = 44
    its (100 - (7)*2-2)/2 i.e. (100 - 7 * 2 - 2) / 2

    Code:
    (PDUCodes(i).Length - Val("&H" & Mid(PDUCodes(i), 1, 2)) * 2 - 2) / 2
    (       100         -    (               7             ) * 2 - 2) / 2
    If you type in your immediate window...
    ? (100 - 7 * 2 - 2)/2
    you get
    42

    The order of operations is:
    Code:
    (100 - 7 * 2 - 2) / 2
    (100 -  14   - 2) / 2
    (   86       - 2) / 2
    (       84      ) / 2
            42
    Last edited by passel; Feb 8th, 2018 at 02:28 PM.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2017
    Posts
    89

    Re: SMS PDU Calculation

    OKdoki!!

    Yep!! I discovered it after you said... p a r e n t h e s i s huh!!

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width