Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Channel Surfer

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()
m.simpleMarkupList ="SimpleMarkupList")
m.simpleMarkupGrid ="SimpleMarkupGrid")
m.ContentTask = createObject("RoSGNode","ContentReader")
m.ContentTask.ObserveField("content", "setcontent")
m.ContentTask.control = "RUN"
m.simpleMarkupList.ObserveField("itemFocused", "onFocusChanged")
end sub
sub setcontent()
Function setgrid()
data = CreateObject("roSGNode", "ContentNode")
dataItem= data.CreateChild("SimpleGridItemData")
dataItem.slot= m.simpleMarkupGrid.content.slot
return data
end function

The debugger shows:
BrightScript Debugger> ENTER LOAD DATA. . .
<Component: roSGNode> =
    metadata: <Component: roContentMetadata>
    change: <Component: roAssociativeArray>
    focusable: false
    focusedChild: <Component: roInvalid>

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
#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
Roku Guru

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!!!! 
0 Kudos
Channel Surfer

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
Roku Guru

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!
Channel Surfer

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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.