in a recent change in the implimentation of my program, I’ve come across an absurd issue where I cannot set a roMessagePort to a variable I’m using to obtain a json string from a url. This is a vital part of my program that worked perfectly fine until this most recent change. If somebody could help me figure out what’s gone wrong, I would appreciate it. I am absolutely clueless here!
[spoiler=the function involving the issue:1rzxtv5u]
Function GetJson(url as String) as string
data = CreateObject("roString")
port = CreateObject("roMessagePort")
urlLink = CreateObject("roUrlTransfer")
urlLink.SetMessagePort(port) 'the function crashes at this line, saying
urlLink.setUrl(url) '"dot opperator attempted with invalid brightscript component or interface reference"
urlLink.SetCertificatesFile("common:/certs/ca-bundle.crt")
urlLink.InitClientCertificates()
if(urlLink.AsyncGetToString())
finished = False
while not finished
msg = wait(0, port)
if msg = invalid
finished = True
urlLink.AsyncCancel()
else
if type(msg) = "roUrlEvent"
finished = True
if msg.GetInt() = 1
response = msg.GetResponseCode()
if response <> 200
print "failure! response code "; response
else
data = msg.GetString()
end if
end if
else
return invalid
end if
end if
end while
end if
return data
end function
[/spoiler:1rzxtv5u]
[spoiler=code leading up to said issue:1rzxtv5u]
function GetServices()
link_str = "url removed for privacy reasons"
json_str = GetJson(link_str)
json = ParseJson(json_str)
recent = GetRecentSermons(json)
return recent
end function
sub init()
'we can add a background here
'm.top.backgroundURI= some image url
m.layoutgroup = m.top.findNode(“MainScreenGroup”)
m.layoutgroup.setFocus(true)
devInfo = createObject(“roDeviceInfo”)
UIResolution = devInfo.getUIResolution()
lgr = m.layoutgroup.boundingRect()
lglr = m.layoutgroup.localBoundingRect()
x = -lgr.x + (UIResolution.width - lglr.width) / 2
y = -lgr.y + (UIResolution.height - lglr.height) / 2
m.layoutgroup.translation = [x, y]
m.services = GetServices()
…
end sub[/spoiler:1rzxtv5u]
[spoiler=Juuuuuuuust in case, this is the xml material involved:1rzxtv5u]<?xml version="1.0" encoding="utf-8"?>
