Home AMX User Forum AMXForums Archive Threads Residential Forum

Parsing Data

I am parsing HTML sata and here is what I have so far

Data_Event[dvDevice1]
{
Online:
{
Client_Connection_Status = 'ONLINE'
}
String:
{
If(Find_String(tide_Buffer,'Predicted Tides:',1))
{
tide_Trash = Remove_String(tide_Buffer,'Predicted Tides:',1)
tide_trash1 = REMOVE_STRING(Tide_Buffer,'</td></tr></table>',1)
tide_trash = REMOVE_STRING(Tide_Buffer,'35px;',3)
tide_time1 = Mid_String(Tide_Buffer,5,8)
tide_Trash2 = REMOVE_STRING(Tide_Buffer,'black',3)
tide_data1 = mid_string(Tide_Buffer,6,4)
tide_Trash3 = Remove_String(Tide_Buffer,'align="right">',1)
tide_time2 = LEFT_STRING(Tide_Buffer,8)
tide_Trash4 = REMOVE_STRING(tide_buffer,'<td>',1)
tide_data2 = mid_string(Tide_Buffer,1,4)
tide_Trash5 = REMOVE_STRING(Tide_Buffer,'70px;',1)
tide_feet2 = mid_string(Tide_Buffer,3,8)
(*******) SEND_STRING dvmaster,tide_buffer
//tide_trash1 = remove_string(Tide_Buffer,'<td align="right">',1)
//tide_time3 = left_string(Tide_Buffer,8)
//tide_trash2 = remove_string(Tide_Buffer,'</td><td>',1)
//tide_data3 = left_string(Tide_Buffer,4)
}

Can I have this many remove strings and left strings in my string event?

I notice at the send string marked above my program gets confused and sends me back the wrong information even though the remove string is precise to what the HTML source document states.

I didnt know if there was a limit of commands you can use for string events

Comments

  • jjamesjjames Posts: 2,908
    Just curious - isn't tide data rather consistent? Can you just use this and put it in a table and read it from there?

    http://www.boatma.com/tides/tides_southshore.html

    I'd personally get rid of the HTML parsing and go a different route, even if that means updating it every 6 months. HTML is too inconsistent to try to parse; at least XML & RSS streams (if available) are pretty consistent.

    Anyway . . . . the short answer to your question is yes - you can put as much in there as you want. Just remember that the REMOVE_STRING function doesn't require the trash to go anywhere - you can just do REMOVE_STRING without assigning the returned value to anything.
  • thomodthomod Posts: 11
    David-
    I started this with J's method - you can get a year's worth of data pretty easily here:

    http://co-ops.nos.noaa.gov/tides09/tab2ec1b.html

    and that can be put into a text file easily, then the thought was to display it like the attached so the days when there is only 3 tides, it will still look good.

    Yes, you'd have to do this every year, but even if it wasn't available any longer from the above site, the data is easy enough to get from many places, and you just never know how someone will change the html (seems like even a very minor change would break the parsing routine).

    J-
    So, is the most efficient way to get the data displayed just to leave it in a straight text file and search for the current date?
  • jjamesjjames Posts: 2,908
    Hey Eric, good to see ya!

    What I'd do is put the file on the master (via FTP) and read the data as needed. I'd probably put an end delimiter on each line to make it easier, but I think there's a function that you can just read one line at a time. The other advantage to putting it on the master via FTP is it doesn't require a reboot of the master. And if you want to get REALLY fancy, host the file somewhere on the web and have all your masters go out and get the file every January to grab the updated version. This way, it's completely automated.

    BTW - is that your panel? Looks good! Though I'm not sure I'd want it to be 100 when it's raining - that could cause problems! :D (j/k)
  • thomodthomod Posts: 11
    j-

    That is the weather page from AMXHome, I just added the tide block in the lower corner.

    I'll read up on the local data access from an FTP'd file - just need the time to focus on this stuff...
    ...come to think of it, I do have an RMS server at my disposal...

    thanks
    -eric
Sign In or Register to comment.