Need help converting to ASCII Hex format


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Darrel something is not going in my head.
    Code:
    Value = 01389 ' <- Is the "0" really included ?

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The compiler will ignore any leading 0's.
    That's the way Tcbcats showed it, so I left it in there.
    <br>
    DT

  3. #3
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    @Darrel
    i mean this line.

    Code:
    For DigLoop = 5 to 1 STEP -2
        Buf((6-DigLoop)/2) ' = Buf((6-5)/2) = 0.5 ??? Does it really works? Round it to zero?
    Next DigLoop
    I don´t tried it out, maybe it works

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Sure it works.

    But PBP uses integer math. So there are no decimals.

    With STEP -2 the loop will execute 3 times, with the values 5, 3, 1 in DigLoop.
    Since it's Integer math, (6-DigLoop)/2 will return 0, 1 and 2 respectively.

    Code:
    loop    Buf((6-DigLoop)/2) = ((Value DIG DigLoop) << 4) + Value DIG (DigLoop -1)
    5       BUF(      0      ) = (       $00              ) +        0  = $00
    3       BUF(      1      ) = (       $10              ) +        3  = $13
    1       BUF(      2      ) = (       $80              ) +        9  = $89
    hth,
    DT

Similar Threads

  1. Hex converting
    By Andre_Pretorius in forum General
    Replies: 9
    Last Post: - 26th June 2009, 02:48
  2. hex ascii help please
    By ffr58kk90 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 29th December 2006, 21:09
  3. Converting ASCII to HEX
    By BobP in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 27th September 2006, 10:21
  4. ascii characters to hex
    By Peter1960 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 26th January 2006, 04:06
  5. Converting Bytes from hex to Dec
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 8th April 2005, 19:44

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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