Forum Discussion

Blackhawk's avatar
Blackhawk
Roku Guru
10 years ago

Install error

I have an install error when I tried to add this code on my channel


Function Main() as void
m.menuFunctions = [
PlayLiveFeed,
CreateArchiveMenu
]
screen = CreateObject("roListScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
InitTheme()
screen.SetHeader("Welcome to Griffin TV")
screen.SetBreadcrumbText("Menu", "Archive")
contentList = InitContentList()
screen.SetContent(contentList)
screen.show()
while (true)
msg = wait(0, port)
if (type(msg) = "roListScreenEvent")
if (msg.isListItemFocused())
screen.SetBreadcrumbText("Menu", contentList[msg.GetIndex()].Title)
else if (msg.isListItemSelected())
m.menuFunctions[msg.GetIndex()]()
endif
endif
end while
End Function

Function InitTheme() as void
app = CreateObject("roAppManager")

listItemHighlight = "#FFFFFF"
listItemText = "#707070"
brandingGreen = "#37491D"
backgroundColor = "#e0e0e0"
theme = {
BackgroundColor: backgroundColor
OverhangSliceHD: "pkg:/images/Overhang_Slice_HD.png"
OverhangSliceSD: "pkg:/images/Overhang_Slice_HD.png"
OverhangLogoHD: "pkg:/images/channel_diner_logo.png"
OverhangLogoSD: "pkg:/images/channel_diner_logo.png"
OverhangOffsetSD_X: "25"
OverhangOffsetSD_Y: "15"
OverhangOffsetHD_X: "25"
OverhangOffsetHD_Y: "15"
BreadcrumbTextLeft: brandingGreen
BreadcrumbTextRight: "#E1DFE0"
BreadcrumbDelimiter: brandingGreen

ListItemText: listItemText
ListItemHighlightText: listItemHighlight
ListScreenDescriptionText: listItemText
ListItemHighlightHD: "pkg:/images/select_bkgnd.png"
ListItemHighlightSD: "pkg:/images/select_bkgnd.png"
CounterTextLeft: brandingGreen
CounterSeparator: brandingGreen
GridScreenBackgroundColor: backgroundColor
GridScreenListNameColor: brandingGreen
GridScreenDescriptionTitleColor: brandingGreen
GridScreenLogoHD: "pkg://images/HDPoster.png"
GridScreenLogoSD: "pkg://images/SDPoster.png"
GridScreenOverhangHeightHD: "138"
GridScreenOverhangHeightSD: "138"
GridScreenOverhangSliceHD: "pkg:/images/Overhang_Slice_HD.png"
GridScreenOverhangSliceSD: "pkg:/images/Overhang_Slice_HD.png"
GridScreenLogoOffsetHD_X: "25"
GridScreenLogoOffsetHD_Y: "15"
GridScreenLogoOffsetSD_X: "25"
GridScreenLogoOffsetSD_Y: "15"
}
app.SetTheme( theme )
End Function



Function InitContentList() as object
contentList = [

{
Title: "Live",
ID: "2",

HDBackgroundImageUrl: "pkg:/images/lvstreaming_304x237.png",
SDBackgroundImageUrl: "pkg:/images/lvstreaming_304x237.png",
ShortDescriptionLine1: "Live Broadcast",
ShortDescriptionLine2: "Live events are shown here"

},
{
Title: "Archive",
ID: "3",

HDBackgroundImageUrl: "pkg:/images/HDPoster.png",
SDBackgroundImageUrl: "pkg:/images/SDPoster.png",
ShortDescriptionLine1: "Archive Menu",
ShortDescriptionLine2: "Choose from a library of videos"
}

]
return contentList
End Function



Is there any way to fix it?

22 Replies

  • destruk's avatar
    destruk
    Streaming Star
    If it can't parse the xml then it will fail there.
    I would suggest putting a stop command before the
    responsexml=parsexml(rsp)

    Then in the debugger when it stops print rsp
    If something shows up then the rsp is ok - and single step the lines until you see the issue.
    Ideally for debugging you wouldn't want to replace the variable you are working with or a failure will lose data, so -
    responseXML = ParseXML(rsp)
        responseXML2 = responseXML.GetChildElements()
        responseArray = responseXML2.GetChildElements()

    It's trying to pick out the data two levels deep of children.  A better laid-out xml feed would make it easier to deal with, but without control of the feed this is one way to do it.
  • You're going to have a tough time making any progress if you're not checking for errors. Your code just blindly assumes that everything just works until it eventually crashes.

    For example, the following GetString() code will fail to return any XML because it can't access your web site at the url you specified (the nameservers aren't set up):
    url.SetUrl("http://.../categories.xml")
    rsp = url.GetToString()


    At the very least, you need to check that the rsp value is non-blank before attempting to parse the result, and print some kind of error message to the debug console.

    Then you're calling:
    responseXML = ParseXML(rsp)

    again, without checking whether or not it parsed (ParseXML returns invalid), which it won't because you're just passing in an empty string from the previous GetToString() call.

    In general, any time a function call can return something you're not expecting and that your subsequent code is not set up to handle (invalid, empty string, etc.) you should check for that at the time, otherwise your program may stumble on for several more statements before it finally crashes, and you'll have a really hard time figuring out where the problem originated.