regex = CreateObject("roRegex", ":(\s*)([0-9]{9,})", "")
safeResult = regex.ReplaceAll(jsonstring ,":\1" + Chr(34) + "\2" + Chr(34))
result = ParseJson(safeResult)
data = m.data()
searchRequest = data.searchRequest
searchRequest.SetURL(url)
print " regex "
regex = data.regex
print "GETting SAFE RESULT for "regex
safeResult = regex.ReplaceAll(searchRequest.getToString(),":\1" + Chr(34) + "\2" + Chr(34))
print " LOADING..."
json = ParseJSON(safeResult)
data : function ()
var = {
searchRequest : CreateObject("roUrlTransfer")
regex : CreateObject("roRegex", ":(\s*)([0-9]{9,})", "")
}
return var
end function
searchRequest.setMessagePort(m.port)
searchRequest.SetURL(url)
timeout = 0
if ( searchRequest.AsyncGetToString())
while(true)
msg = wait (10,m.port)
print "typ msg "type(msg)
timeout = timeout + 10
if (type(msg) = "roUrlEvent")
code = msg.GetResponseCode()
if (code = 200)
search = searchRequest.getToString()
exit while
end if
else if (timeout = 5000 )
print "error"
return invalid
end if
end while
end if
"RokuMarkn" wrote:
1. Getting an invalid msg is normal when you have a timeout on your wait. It just means the timeout expired. Generally you should test type(msg) and only process messages of the type you care about. You should just ignore messages of other types (including invalid). This is a very important principle which should be used in all event loops.
I am getting invalid when running this