New topic: Datagram to string array
<http://forums.realsoftware.com/viewtopic.php?t=26183> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message carlfitzsimmons Post subject: Datagram to string arrayPosted: Sat Jan 24, 2009 12:36 pm Joined: Tue Sep 19, 2006 5:10 pm Posts: 72 I have a response that is coming from a UDP device that I need to split up. The response contains 6 bytes of a MAC and 2 byte firmware all is preceded by the response code which is 4 letters. There is nothing to parse the data on either like * or something like that. I have not been able to figure out how to get the datagram into a string array and then parse on the known boundaries which should be 4bytes 6bytes 2bytes. 4 bytes - response code 6 bytes - MAC 2 bytes - Version number When parsed correctly each will contain an ASCII equivalent and will be placed on the same line in a listbox. Here is the code I am currently using. Dim n, m, l As Integer Dim my_str_array() As String Listbox2.AddRow "" ListBox2.ColumnType(0) = ListBox.TypeEditable m = Listbox1.ListCount-1 my_str_array = Split(my_datagram.Data, EndOfLine) l = Len(my_datagram.Data) For n = 0 to Len(my_datagram.Data) ListBox2.Cell(m,0) = my_str_array(n) Next Once I can do this correctly I will place the byte boundary values together and convert to ASCII. When I get to this line of code - ListBox2.Cell(m,0) = my_str_array(n) I receive an out of bounds failure. In the debugger I see the contents in my_str_array. After the first 4 characters the data is unreadable which is why I need to parse/convert to display correctly. Any suggestions would be welcomed. Thanks - Carl Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 900 classes with 18000 functions in one REALbasic plug-in. The Monkeybread Software Realbasic Plugin v8.1. <http://www.monkeybreadsoftware.de/realbasic/plugins.shtml> [email protected]
