String Parsing


Closed Thread
Results 1 to 2 of 2

Thread: String Parsing

  1. #1
    eoasap's Avatar
    eoasap Guest

    Default String Parsing

    if i receive serially a string like this, i'll refer to this
    string as 'ALL'
    ALL = 1.4,832.5,( ... etc, keeps going)

    i am trying to store store each value in between commas as a separate variable. i already know that string 'ALL' is correct because if i output the string to LCD it shows up perfect, but something must be wrong with my processing of each individual substring.

    this is how i'm trying to do it:

    i = 0
    j = 0

    loop1:
    if ALL[i] != "," then
    hdop[i] = ALL[i]
    hdopsize = i
    i = i + 1
    goto loop1
    endif

    i = i+1 'get off the comma and go to next data

    loop2:
    if ALL[i] != "," then
    j = i - hdopsize - 1 'i = hdopsize + comma + altitude[j]
    altitude[j] = ALL[i]
    altitudesize = j
    i = i + 1
    goto loop2
    endif


    ok i'm hoping that at this point to have two variables, in this case i expect this:
    hdop = 1.4
    hdopsize = 3

    altitude = 832.5
    altitudesize = 5

    so i should be able to output the variables to LCD as follows:

    lcdout cmd, clr
    lcdout cmd, line1, "HDOP = "
    lcdout str hdop\hdopsize

    lcdout cmd, line2, "Altitude = "
    lcdout str altitude\altitudesize



    it all seems right to me, but its not working right.
    hdopsize and altitudesize are bytes
    hdop and altitude are defined as byte arrays length 10
    (an unknown value, but no larger than 10)

    can anyone see any obvious errors with my code?

  2. #2
    eoasap's Avatar
    eoasap Guest


    Did you find this post helpful? Yes | No

    Default

    ok i found the error (duh!) i am reading backwards from how the variable is stored. i'll leave this up in case anyone else makes the same mistake
    Last edited by eoasap; - 18th February 2006 at 17:24.

Similar Threads

  1. Hserin parsing string...again?
    By kevlar129bp in forum Serial
    Replies: 21
    Last Post: - 9th July 2012, 16:35
  2. parsing string from hserin
    By xxxxxx in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 2nd April 2009, 18:42
  3. Visual Basic 6 & Access 2000
    By Demon in forum Off Topic
    Replies: 33
    Last Post: - 7th September 2006, 04:39
  4. Serial String parsing
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th June 2005, 18:11
  5. serial string parsing
    By billybobbins in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 8th September 2004, 21:34

Members who have read this thread : 2

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