Parsing Strings...


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Feb 2009
    Posts
    41


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,

    I think your latest solution might have worked, but I had already got it working by parsing it after the fact based on Jersons parse routine. I really appreciate everyones input. Here is what the working code looks like:

    hserIN 65535, oops, [STR inputdata\12\10] 'get the serial data
    gosub ParseNumber 'split the raw data into 2 numbers

    ParseNumber: ' collect both pieces of the data in sep arrays
    for Cntr = 0 to 10
    if inputdata[Cntr] <> "," then ' Found comma? We've got first
    smallp[Cntr] = inputdata[Cntr]
    else

    Cntr2 = Cntr 'marks where the comma was
    'goto earlyexit
    goto GetNum2 ' Now get the second number
    endif
    next
    earlyexit:
    return

    GetNum2:
    CNTR = Cntr + 1 'get past the comma
    for Cntr = Cntr to 10
    if inputdata[Cntr] < "0" then
    RETURN
    else
    If inputdata[Cntr] > "9" then
    RETURN
    ELSE
    largep[Cntr-Cntr2-1] = inputdata[Cntr] ' It's a valid number
    endif
    ENDIF
    next

    return

    I had to modify the array pointer for the second number by subtracting the point at which the comma was found on the first pass from it's pointer. In other words the pointer for the input data can't be used directly to point to the second number.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    <b>Proof Again</b> There is more than 1 right way to do almost everything.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Parsing serial data
    By Heckler in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th March 2010, 14:25
  2. Please help with storing strings in codespace
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th May 2008, 01:02
  3. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 06:26
  4. Processing lengthy strings
    By sougata in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st March 2006, 05:27
  5. I2CWRITE writing Strings to EEPROM
    By NavMicroSystems in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 27th March 2005, 19:45

Members who have read this thread : 1

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