ASCII to Long conversion


Results 1 to 7 of 7

Threaded View

  1. #7
    Join Date
    Feb 2009
    Posts
    41


    Did you find this post helpful? Yes | No

    Default

    Hi Jerson and Jerry,

    I appreciate the help from both of you. I was able to take the parts I liked best from both of your functions and merge them into this....

    MyData var byte[5] 'Data array
    LongData var long 'Base ten multiplier
    Index var byte 'Array index

    LongData = 0 'Initialize the variable

    For Index = 0 to 4 step 1 ' potential non-digits in MB locations
    If MyData[Index] > 47 AND MyData[index] < 58 Then ' allow only ascii digits 0 to 9
    LongData = LongData * 10 ' carry it over
    LongData = LongData + MyData[Index] - 48 ' subtract away ASCII offset
    ENDIF
    NEXT Index

    HSEROUT [DEC LongData]


    I've tested it by feeding it some array data like this:

    MyData[0] = "7"
    MyData[1] = "1"
    MyData[2] = "0"
    MyData[3] = "9"
    MyData[4] = " "

    and the serial port data (the Long) reflects the ASCII data, so it seems like we have success!

    Thanks again!
    TR
    Last edited by TerdRatchett; - 6th March 2009 at 00:06.

Similar Threads

  1. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  2. Convert long binary number to ASCII Decimal
    By Joe Rocci in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 9th July 2009, 13:58
  3. SerIn2 ASCII Conversion
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 4th March 2008, 21:41
  4. ascii conversion help needed
    By muddy0409 in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 13th January 2007, 06:33
  5. Conversion of 10-bit word into ASCII
    By Barry Johnson in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th January 2005, 14:26

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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