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: 
btpoole
Level 7

Syntax Error While Loading Content

The following code gives me a syntax error and I don't really understand why. I get a syntax error where dataItem.slot=m.simpleMarkupGrid.content.slot. I am adding
slot field in an interface.  I know from the ?dataItem and ?dataItem.hasfield("slot") the field is there. I can even set the value of slot to a string "test" and it shows up. The
value of slot coming from the task is also populated. I have check it in the task and even printed it and it has value.

EDIT: I don't know if this makes a difference but maybe, I am using the task to create 2 url transfers in the same function and one content node. The first reads a json file and parses to get channel names (title) the second then reads a json file and parses to get show times (slot). As shown in the code the list and grid contents come from the same task. I don't see why this would cause a problem but I am probably wrong.

Sub init()
?"ENTER LOAD DATA. . ."
m.simpleMarkupList = m.top.findNode("SimpleMarkupList")
m.simpleMarkupGrid = m.top.findNode("SimpleMarkupGrid")
m.ContentTask = createObject("RoSGNode","ContentReader")
m.ContentTask.ObserveField("content", "setcontent")
m.ContentTask.control = "RUN"
?"TASK RAN"
m.simpleMarkupGrid.content=setgrid()
m.simpleMarkupList.ObserveField("itemFocused", "onFocusChanged")
end sub
sub setcontent()
?"IN SETCONTENT"
m.simpleMarkupList.content=m.ContentTask.content
m.simpleMarkupList.SetFocus(true)
m.simpleMarkupGrid.content=m.ContentTask.content
Function setgrid()
?"IN SETGRID"
data = CreateObject("roSGNode", "ContentNode")
dataItem= data.CreateChild("SimpleGridItemData")
?dataItem
?dataItem.hasfield("slot")
dataItem.slot= m.simpleMarkupGrid.content.slot
return data
end function

The debugger shows:
BrightScript Debugger> ENTER LOAD DATA. . .
TASK RAN
IN SETGRID
<Component: roSGNode> =
{
    metadata: <Component: roContentMetadata>
    change: <Component: roAssociativeArray>
    focusable: false
    focusedChild: <Component: roInvalid>
    id: 
    slot: 
}
true

Current Function:
022:  Function setgrid()
023:  ?"IN SETGRID"
024:  data = CreateObject("roSGNode", "ContentNode")
025:  dataItem= data.CreateChild("SimpleGridItemData")
026:  ?dataItem
027:  ?dataItem.hasfield("slot")
028:* dataItem.slot= m.simpleMarkupGrid.content.slot
029:  return data
030:  end function
Syntax Error. (runtime error &h02) in pkg:/components/entry.brs(28)
028: dataItem.slot= m.simpleMarkupGrid.content.slot
Backtrace:
#1  Function setgrid() As Dynamic
   file/line: pkg:/components/entry.brs(28)
#0  Function init() As Void
   file/line: pkg:/components/entry.brs(10)
Local Variables:
global           rotINTERFACE:ifGlobal
m                roAssociativeArray refcnt=4 count:5
data             bsc:roSGNode refcnt=1
dataitem         bsc:roSGNode refcnt=1
0 Kudos
4 Replies
joetesta
Level 10

Re: Syntax Error While Loading Content

I don't know why it's a syntax error but after the crash you could poke around in debugger and see what the following return, maybe some clues or enlightenment:
? m.simpleMarkupGrid
? m.simpleMarkupGrid.content
? m.simpleMarkupGrid.content.slot

PS: DAMN this POS wysiwyg interface that makes me edit every one of my posts to strip out BS markup that leaks through in the post!!!! 
aspiring
0 Kudos
btpoole
Level 7

Re: Syntax Error While Loading Content

You have that problem also, thought it was just me. As for syntax error, no clue. I deleted out several lines, retyped and error went away, for now. Really odd, I can type in lines of code or copy and paste from the sdk examples and get errors, take them out and do the exact same thing and no errors. I do mean the exact same thing. Bet I have cut and re input lines a hundred times.
Thanks again for looking at it.
0 Kudos
EnTerr
Level 8

Re: Syntax Error While Loading Content

@joetesta has it right -
the problem was in somewhere in the right side. Notice a most unusual diagnostic "Syntax Error. (runtime error &h02)". There is no such thing as a "runtime syntax error", since syntax errors belong to compilation which happened before starting the code. Rather this is execution error, more of a "befuddled error". Here is quick&dirty reproduction:
BrightScript Debugger> m.a = 7

BrightScript Debugger> ? m.a.b
Syntax Error. (runtime error &h02) in $LIVECOMPILE(33)

And, i am joining you two in wishing to "flour" this POS wysiwyg editor that descended upon us with the "snow blindness" update - cleaning after said editor is a constant battle for me, almost every message!
0 Kudos
btpoole
Level 7

Re: Syntax Error While Loading Content

Thanks EnTerr for more info on it. I have since deleted out code from Task and from the scene and re enter with no errors. Not sure what the deal was or still is but it's running thru now. What's really confusing is that both the task and the scene shows the field to be present and the task was populated when ran.
0 Kudos