Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
Blackhawk
Level 7

Screengraph error

I was working an my channel

' ********** Copyright 2015 Roku Corp.  All Rights Reserved. **********
Sub RunUserInterface()
    screen = CreateObject("roSGScreen")
    scene = screen.CreateScene("HomeScene")
    port = CreateObject("roMessagePort")
    screen.SetMessagePort(port)
    screen.Show()
   
    oneRow = GetApiArray()
    list = [
        {
            TITLE : "First row"
            ContentList : oneRow
        }
           ]
    scene.gridContent = ParseXMLContent(list)
    while true
        msg = wait(0, port)
        print "------------------"
        print "msg = "; msg
    end while
   
    if screen <> invalid then
        screen.Close()
        screen = invalid
    end if
End Sub

Function ParseXMLContent(list As Object)
    RowItems = createObject("RoSGNode","ContentNode")
   
    for each rowAA in list
    'for index = 0 to 1
        row = createObject("RoSGNode","ContentNode")
        row.Title = rowAA.Title
        for each itemAA in rowAA.ContentList
            item = createObject("RoSGNode","ContentNode")
            ' We don't use item.setFields(itemAA) as doesn't cast streamFormat to proper value
            for each key in itemAA
                item[key] = itemAA[key]
            end for
            row.appendChild(item)
        end for
        RowItems.appendChild(row)
    end for
    return RowItems
End Function

Function GetApiArray()
    url = CreateObject("roUrlTransfer")
    url.SetUrl("[url=http://griffingatv.website/xml/categories.xml]http://griffingatv.website/xml/categories.xml[/url]")
    rsp = url.GetToString()
    responseXML = ParseXML(rsp)
    responseXML = responseXML.GetChildElements()
    responseArray = responseXML.GetChildElements()
    result = []
    for each xmlItem in responseArray
        if xmlItem.getName() = "item"           
itemAA = xmlItem.GetChildElements()
            if itemAA <> invalid
                item = {}
                for each xmlItem in itemAA
                    item[xmlItem.getName()] = xmlItem.getText()
                    if xmlItem.getName() = "media:content"
                        item.stream = {url : xmlItem.url}
                        item.PlayContentWithFullRAFIntegration().url
                        item.url = xmlItem.getAttributes().url
                        item.streamFormat = "mp4"
                       
                        mediaContent = xmlItem.GetChildElements()
                        for each mediaContentItem in mediaContent
                            if mediaContentItem.getName() = "media:thumbnail"
                                item.HDPosterUrl = mediaContentItem.getattributes().url
                                item.hdBackgroundImageUrl = mediaContentItem.getattributes().url
                            end if
                        end for
                    end if
                end for
                result.push(item)
            end if
        end if
    end for
    return result
End Function

Function ParseXML(str As String) As dynamic
    if str = invalid return invalid
    xml=CreateObject("roXMLElement")
    if not xml.Parse(str) return invalid
    return xml
End Function

and I had came across this error
Syntax Error (Compile Error h&02) inpkg: source/main.brs (68)
0 Kudos
9 Replies
joetesta
Level 10

Re: Screengraph error

Well what's on line 68???
I copied your code and guessing it's off by a few lines, and it's really crashing on this line because item is an roArray and you try to use it as an roAssociativeArray
 item.stream = {url : xmlItem.url}


                    item[xmlItem.getName()] = xmlItem.getText()  <---- on this line 'item' is an roArray
                    if xmlItem.getName() = "media:content"
                        item.stream = {url : xmlItem.url}        <----- on this line you try to use it as roAssociativeArray, goes boom
aspiring
0 Kudos
belltown
Level 7

Re: Screengraph error

"joetesta" wrote:
item[xmlItem.getName()] = xmlItem.getText()  <---- on this line 'item' is an roArray


There's nothing wrong with that assignment. If xmlItem.getName() returns a String, then item is being used (correctly) as an associative array.

It could be anything. My guess is that this is the problem:
item.PlayContentWithFullRAFIntegration().url


@Blackhawk. If you're serious about getting other people to do your debugging for you, then the least you could do is cut and paste the debugger output -- the WHOLE debugger output, not just a single line from it, and include the debugger listing that shows the LINE NUMBERS of your code.
https://github.com/belltown/
0 Kudos
joetesta
Level 10

Re: Screengraph error

Looks like you're correct belltown. Does the response from PlayContentWithFullRAFIntegration() have a url key, is it even an roAA (not according to your (Blackhawk's) earlier posts)?
aspiring
0 Kudos
Blackhawk
Level 7

Re: Screengraph error

Thats what it said according to PuTTY
0 Kudos
belltown
Level 7

Re: Screengraph error

It looks like a compile error rather than a runtime error, which is why it isn't giving more information. You should be able to look at the line number in the code that it's telling you has an error, and figure out what's wrong.
https://github.com/belltown/
0 Kudos
Blackhawk
Level 7

Re: Screengraph error

I had redid the main script to this
********** Copyright 2015 Roku Corp.  All Rights Reserved. **********
Library "Roku_Ads.brs"
Sub RunUserInterface()
    screen = CreateObject("roSGScreen")
    scene = screen.CreateScene("HomeScene")
    port = CreateObject("roMessagePort")
    screen.SetMessagePort(port)
    screen.Show()
   
    oneRow = GetApiArray()
    list = [
        {
            TITLE : GetApiArray.category()           ContentList : oneRow
        }
           ]
    scene.gridContent = ParseXMLContent(list)
    while true
        msg = wait(0, port)
        print "------------------"
        print "msg = "; msg
    end while
   
    if screen <> invalid then
        screen.Close()
        screen = invalid
    end if
End Sub

Function ParseXMLContent(list As Object)
    RowItems = createObject("RoSGNode","ContentNode")
   
    for each rowAA in list
    'for index = 0 to 1
        row = createObject("RoSGNode","ContentNode")
        row.Title = rowAA.Title
        for each itemAA in rowAA.ContentList
            item = createObject("RoSGNode","ContentNode")
            ' We don't use item.setFields(itemAA) as doesn't cast streamFormat to proper value
            for each key in itemAA
                item[key] = itemAA[key]
            end for
            row.appendChild(item)
        end for
        RowItems.appendChild(row)
    end for
    return RowItems
End Function

Function GetApiArray()
    url = CreateObject("roUrlTransfer")
    url.SetUrl("[url=http://api.delvenetworks.com/xml/categories.xml]http://api.delvenetworks.com/xml/categories.xml[/url]")
    rsp = url.GetToString()
    responseXML = ParseXML(rsp)
    responseXML = responseXML.GetChildElements()
    responseArray = responseXML.GetChildElements()
    result = []
    for each xmlItem in responseArray
        if xmlItem.getName() = "item"
            itemAA = xmlItem.GetChildElements()
            if itemAA <> invalid
                item = {}
                for each xmlItem in itemAA
                    item[xmlItem.getName()] = xmlItem.getText()
                    if xmlItem.getName() = "media:content"
                        item.stream = {url : xmlItem.url}
                        item.url = xmlItem.getAttributes().url
                        item.streamFormat = "mp4"
                       
                        mediaContent = xmlItem.GetChildElements()
                        for each mediaContentItem in mediaContent
                            if mediaContentItem.getName() = "media:thumbnail"
                                item.HDPosterUrl = mediaContentItem.getattributes().url
                                item.hdBackgroundImageUrl = mediaContentItem.getattributes().url
                            end if
                        end for
                    end if
                end for
                result.push(item)
            end if
        end if
    end for

shouldPlayContent = true
adBreakIndex = 0
while shouldPlayContent
  videoMsg = wait(0, mediaContent.GetMessagePort())
  if videoMsg.isPlaybackPosition()
    curPos = videoMsg.GetIndex()
    nextPod = scheduledPods[adBreakIndex]
    if curPos > nextPod.renderTime and not nextPod.viewed
      contentVideoScreen.Close() ' stop playback of content
      mediaContent = RAF.showAds(nextPod) ' render next ad pod
      adBreakIndex = adBreakIndex + 1
 
    end if
  end if

end while

    return result
End Function

Function ParseXML(str As String) As dynamic
    if str = invalid return invalid
    xml=CreateObject("roXMLElement")
    if not xml.Parse(str) return invalid
    return xml
End Function

I keep getting Syntax Error (compile error &h02) on 1, 3, 5, 21, 22

PuTTY didnt explain the error. I think 3 or 5 has something to do with TITLE : GetApiArray.category()      
0 Kudos
RokuMarkn
Level 7

Re: Screengraph error

Please read again what belltown posted back on April 6:

@Blackhawk. If you're serious about getting other people to do your debugging for you, then the least you could do is cut and paste the debugger output -- the WHOLE debugger output, not just a single line from it, and include the debugger listing that shows the LINE NUMBERS of your code.

Instead, you said "I keep getting Syntax Error (compile error &h02) on 1, 3, 5, 21, 22".  That one line is not the WHOLE debugger output, is it?  No one can help you if you keep hiding the debugger output from us.

--Mark
0 Kudos
destruk
Level 10

Re: Screengraph error

Well, first off your line 1 of that script as you "redid" it - is missing the rem or comment apostrophe at the beginning, so this:
********** Copyright 2015 Roku Corp.  All Rights Reserved. **********


Is not executable code.  Delete the line, preface it with a "REM " or put the apostrophe back ' in front of that.  Then rezip, reinstall, and try running it again to look at the next line it doesn't like.
0 Kudos
belltown
Level 7

Re: Screengraph error

"RokuMarkn" wrote:
Please read again what belltown posted back on April 6:

@Blackhawk. If you're serious about getting other people to do your debugging for you, then the least you could do is cut and paste the debugger output -- the WHOLE debugger output, not just a single line from it, and include the debugger listing that shows the LINE NUMBERS of your code.

Instead, you said "I keep getting Syntax Error (compile error &h02) on 1, 3, 5, 21, 22".  That one line is not the WHOLE debugger output, is it?  No one can help you if you keep hiding the debugger output from us.

--Mark

It actually looks like those are compile-time syntax errors that occur when trying to side-load the channel, rather than run-time debugger errors, in which case that's all the information you get. Still, posting a bunch of line numbers and a snippet of un-numbered code, and leaving the rest of us to figure out which line is which (especially when the code he posts doesn't always seem to be the actual code that was used),  seems like he's not putting a whole lot of effort into helping himself.
https://github.com/belltown/
0 Kudos