Page 1 of 1

Alphanumeric List Property Help

Posted: Sun Nov 26, 2006 7:05 pm
by Osler
I am having a little trouble populating an alpha-list property with the queue data I obtain from the ZonePlayer. This is the code I use to cycle through the returned xml file and create the CurrentQueue string:

Code: Select all

'TotalMatches is the number of items in the queue - zero based
'Result is the xml document presented as a string

Set xmlData = CreateObject("Microsoft.XMLDom")
xmlData.async = "false"
xmlData.loadXML(Result)
	
Dim I
CurrentQueue = ""
For I = 0 To (CInt(TotalMatches) - 1)
  CurrentQueue = CurrentQueue & CStr(I + 1) & vbTab & xmlData.getElementsByTagName("upnp:album").item(I).text & vbTab & xmlData.getElementsByTagName("dc:title").item(I).text & vbLf
Next

Set xmlData = Nothing
I run this code by itself and I get a correct output. The queue size I am working with is 25 tracks deep.

Now, when I go to put this into an alpha-list property in HouseBot (via COM object) I use this code:

Code: Select all

'appropriate object creation occurs prior to this, of course

Call HBServer.SetPropertyValue("ZonePlayer_Playroom", "ZPQueue", CurrentQueue)

This code causes HouseBot to die and I am not sure why. Commenting it out allows the script to run fine without killing the server. Am I presenting the data as HouseBot anticipates: item <TAB> item <TAB> item <LINEFEED>?

A dump file was not generated with the failure of the HouseBot server.

Osler

Posted: Mon Nov 27, 2006 12:29 pm
by Richard Naninck
Are you aware that the info before the first TAB will never show and is used to store as hidden in the List Properties -> Change Properties. With this feature you can store info in a certain property which can be used to control stuff. If you want to display all of this in the list, use 2 TAB's before starting your info.

CurrentQueue = CurrentQueue & vbTAB & CStr(I + 1) & vbTab & xmlData.getElementsByTagName("upnp:album").item(I).text & vbTab & xmlData.getElementsByTagName("dc:title").item(I).text & vbLf

Also make very sure that all lines have the same amount of TABS, or your output will be distorted.

Posted: Mon Nov 27, 2006 2:55 pm
by Osler
Yes, searching through past posts (yours and others) revealed that the first position is not shown and acts as the "property value position" for the line. That is why I was simply populating it with the index value from the queue.

I will work on this some more tonite. I dunno what the deal is unless I am somehow not passing a string to HouseBot. I'll have to experiment with a simpler VBScript to try to get to the bottom of it. Thanks for the reply.

Osler

Posted: Tue Nov 28, 2006 12:51 am
by Osler
The problem seems to arise when trying to populate the list directly with text derived from an xml document. The GetElementsByTagName().Item().Text is what is causing this to occur. Even if I try to obtain this data and convert it to a string using CStr, it still causes a problem. Using simple stuff, such as "This is a test.", repeatedly to populate a list works just fine. The error that is thrown is shown below as well as the error that shows up when I choos to debug in VC#.

http://home.comcast.net/~jpbrowning2/List_Error.bmp

http://home.comcast.net/~jpbrowning2/List_Error_2.bmp

I hope someone can shed some light on this. Scott...are you out there?

Osler

Posted: Tue Nov 28, 2006 8:18 am
by ScottBot
Osler wrote:... Scott...are you out there?Osler
I'm here. If you can send me something that will allow me to duplicate the issue, I may be able to determine the cause. Send me the data that is causing it to die from the xml file.

Also, if you enter the bad data directly into the UI (instead of using VB Script), does it also die?[/list]

Posted: Tue Nov 28, 2006 9:47 am
by Osler
Scott:

I will try directly enter the data this evening. I have saved the xml delivered from the zoneplayer directly to a txt file. It can be accessed here:

http://home.comcast.net/~jpbrowning2/HouseBot_XML.txt

The ZonePlayer delivers this to the script as a string so this should be an unadulterated version of what I am starting off with prior to loading it into the xmldom.

Osler

Posted: Tue Nov 28, 2006 2:05 pm
by Osler
So little more testing reveals that it is the "size" of the list that is being passed that is causing a problem. Within the xml document I posted, there are 25 songs in the queue. When I cycle through (For I = 0 to 24 below) to build the list, I can pass items 0 to 17 as a list to HouseBot without a problem. As soon as I hit 18 items in the list HouseBot goes belly-up. This is a sample script I am using to load the text file I posted, parse it as an xml document, build the list, and then pass the list to Housebot.

Code: Select all

Dim HBServer
Dim szRSP
Dim Result

Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\Documents and Settings\Jeff\Desktop\HouseBot_XML.txt", ForReading)
Result = f.ReadAll

Dim xmlData
Set xmlData = CreateObject("Microsoft.xmldom")
xmlData.async= "false"
xmlData.loadXML(Result)

Dim CurrentSong
Dim List
List = ""
For I = 0 To 24 'Here lies the problem - go over 17 and the list is "too large" for HouseBot.
	CurrentSong = xmlData.getElementsByTagName("dc:title").item(I).text
	List = List & vbTab & CurrentSong & vbLf
Next

Set HBServer = CreateObject("HBControlMod.HBControl")

szRSP = HBServer.Connect(2525, "127.0.0.1", "")

Call HBServer.SetPropertyValue("ZonePlayer_Family Room", "ZPQueue", List)

Set HBServer = Nothing
Any ideas?

Osler

Posted: Tue Nov 28, 2006 5:10 pm
by ScottBot
I've verified that this is indeed a problem with the external control plugin. Anything over 512 bytes will cause the crash.

I've tested this script running in a VBScript Device and it works without the limitation. Not sure if you can execute it that way or not. I've included my test script below (few of the names have changed, but it's the same data).

Code: Select all

Dim HBServer 
Dim szRSP 
Dim Result 

Const ForReading = 1, ForWriting = 2 
Dim fso, f 
Set fso = CreateObject("Scripting.FileSystemObject") 
Set f = fso.OpenTextFile("C:\temp\bad.xml", ForReading) 
Result = f.ReadAll 

Dim xmlData 
Set xmlData = CreateObject("Microsoft.xmldom") 
xmlData.async= "false" 
xmlData.loadXML(Result) 

Dim CurrentSong 
Dim List 
List = "" 
For I = 0 To 24 'Here lies the problem - go over 17 and the list is "too large" for HouseBot. 
   CurrentSong = xmlData.getElementsByTagName("dc:title").item(I).text 
   List = List & vbTab & CurrentSong & vbLf 
Next 

SetPropertyValue "Null Device.PlayList", List 

Posted: Tue Nov 28, 2006 5:53 pm
by Osler
Excellent. I can just save it to a text file in the Sonos_Control folder and then set a script device to running via external control to look in the text file and populate the alpha list.

It may be more appropriate to do this using the Play List Device. Updating the file would automatically trigger the device to update. What do you think?

Osler

Posted: Tue Nov 28, 2006 6:11 pm
by ScottBot
Sounds like it should work.

Posted: Wed Nov 29, 2006 12:24 pm
by Richard Naninck
Scott,

Is this in any way related to the (bug) I once reported about the max text of 10KB in an alphalist?

If I read it correctly, there is a problem over 512 bytes in the external control device.

Osler, be aware that there is also a max to an alphalist. It can carry as much as 10KB of bytes.
I cap all of my alphalists at 9800 bytes otherwise HB will hang badly.

Posted: Wed Nov 29, 2006 5:11 pm
by ScottBot
Richard,

This problem was specific to the External Control plugin.

I have the 10K limit on my list. Can you point me to the post where this was discussed (sometimes help me to jump back into the issue)?

Posted: Wed Nov 29, 2006 6:40 pm
by Osler
Scott and Richard:

Thank you both for your feedback. It is good to be aware of these things. My initial assumption is always that I am too stupid to figure out what is going on. This is correct most of the time....but its good to know that occassionally there really is a gremlin in the system. I will keep the 10K limit in mind...though off handed, I am unsure as to how to test the "size" of my list in scripting (hobby.....not employed or degreed in any of this stuff).

Osler

Posted: Thu Nov 30, 2006 12:16 pm
by Richard Naninck

Code: Select all

Dim I 
CurrentQueue = "" 
For I = 0 To (CInt(TotalMatches) - 1) 
  CurrentQueue = CurrentQueue & CStr(I + 1) & vbTab & xmlData.getElementsByTagName("upnp:album").item(I).text & vbTab & xmlData.getElementsByTagName("dc:title").item(I).text & vbLf 

If Len(CurrentQueue) > 9800 Then Exit For

Next
Osler,

I set 9800 in the above If so your next inserted item still has 200 bytes before overload. Of your items are larger then 200 bytes, please decrease the 9800 value to the max (+ a few) of the largest item to be inserted.

Scott, the 10K issue was discussed via e-mail. I forwarded the e-mail to you...

Posted: Thu Nov 30, 2006 2:01 pm
by Osler
Excellent and many thanks.

Osler