Rek
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2013
09:35 AM
[SOLVED] Getting weird exception
Hi all, I'm new to roku development, and I'm encountering a strange error that I haven't been able to debug. Was wondering if some of you gurus could lend me your eyes 😄
Basically, I'm trying to create an intrinsic object to wrap up some json rpc functionality, and it keeps crashing whenever I access members of the object (both functions and data members crash).
Here's how I create the object:
Here's the function I'm testing with:
Any ideas what's going on?
Basically, I'm trying to create an intrinsic object to wrap up some json rpc functionality, and it keeps crashing whenever I access members of the object (both functions and data members crash).
Here's how I create the object:
function CreateAPI(hostAddress = "" as string) as object
api = CreateObject("roAssociativeArray")
api.HostAddress = hostAddress
api.ClientID = ""
api.ReceiveResponse = API_Receive
api.Call = API_CALL
return api
end function
Here's the function I'm testing with:
function debugAPI()
print "Creating API object"
api = CreateAPI("http://192.168.128.110/jsonrpc/")
print "Checking validity"
if api = invalid
print "API is invalid"
else
print "API is valid"
end if
print "Calling API(";api.HostAddress;")" <--- This line crashes
result = api.Call("Server.RegisterClient") <--- This one too
print "Execution successful"
end function
Any ideas what's going on?
7 REPLIES 7


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2013
10:05 AM
Re: Getting weird exception
It would be helpful if you shared the text of the crash(es), but off the top of my head...
Probably the nested quotes are the problem. Try something like:
This would initiate a call to a function called API_CALL(). Is that function defined somewhere?
print "Calling API(";api.HostAddress;")" <--- This line crashes
Probably the nested quotes are the problem. Try something like:
print "Calling API(" + Chr(34) + ";api.HostAddress;" + Chr(34) + ")"
result = api.Call("Server.RegisterClient") <--- This one too
This would initiate a call to a function called API_CALL(). Is that function defined somewhere?
Rek
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2013
10:20 AM
Re: Getting weird exception
"RokuChris" wrote:
It would be helpful if you shared the text of the crash(es), but off the top of my head...print "Calling API(";api.HostAddress;")" <--- This line crashes
Probably the nested quotes are the problem. Try something like:print "Calling API(" + Chr(34) + ";api.HostAddress;" + Chr(34) + ")"result = api.Call("Server.RegisterClient") <--- This one too
This would initiate a call to a function called API_CALL(). Is that function defined somewhere?
There are no nested quotes. Just to be sure though, I tried this and it still crashes:
print api.HostAddress
Here's the error text:
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in ...3W3UR/pkg:/source/appMain.brs(23)
023: print api.HostAddress
And yes, API_Call is defined. Thanks for the quick response by the way 🙂
Rek
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2013
10:51 AM
Re: Getting weird exception
Ok, here's some more information... apparently intrinsic objects don't work after being returned from a function?
function CreateAPI() as object
api = {}
return api
end function
function debugAPI()
print "Creating API object"
api = CreateAPI()
api.HostAddress = "test" <-- This line crashes... It should just be an
empty roAssociativeArray right? Why would this fail?
print "Checking validity"
if api = invalid
print "API is invalid"
else
print "API is valid"
end if
print "Execution successful"
end function


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2013
11:21 AM
Re: Getting weird exception
The crash indicates that your api variable is invalid for some reason.
But that latest snippet works fine for me. I get this on the console:
But that latest snippet works fine for me. I get this on the console:
Creating API object
Checking validity
API is valid
Execution successful
Rek
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2013
11:55 AM
Re: Getting weird exception
"RokuChris" wrote:
The crash indicates that your api variable is invalid for some reason.
But that latest snippet works fine for me. I get this on the console:Creating API object
Checking validity
API is valid
Execution successful
I tried making a new project and running that snippet, and it works for me there too. I suspect the error message is completely wrong, and I need to look somewhere else.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2013
12:32 PM
Re: Getting weird exception
"Rek" wrote:
I tried making a new project and running that snippet, and it works for me there too. I suspect the error message is completely wrong, and I need to look somewhere else.
It sounds to me like you're either inadvertently overwriting the api variable at some point, or CreateAPI isn't returning what you think it is. Could you post the actual code you're using?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Rek
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2013
01:56 PM
Re: Getting weird exception
Thanks for the help guys, I have worked it out. It was completely unrelated to the code in question. There was a failed UrlTransfer happening, and for whatever reason, it was reporting it as being caused by the wrong line. At least I'm fairly certain that's what was happening... I made sure the UrlTransfer fails cleanly and its no longer an issue. Cheers.