Was looking for a way to determine if a file exist on my server from the Roku. I came across a function created and posted in another post:
http://forums.roku.com/viewtopic.php?f=34&t=33829&p=215631&hilit=check+for+file+exist#p215658. Here is the code:
Function fileExists(fileName As String) As Boolean
LocalFile = CreateObject("roRegex", "pkg:", "i")
LiveFile = CreateObject("roRegex", "http:", "i")
if(true = LocalFile.IsMatch(fileName))
LocalFileBrowser = CreateObject("roFileSystem")
return LocalFileBrowser.Exists(fileName)
else if(true = LiveFile.IsMatch(fileName))
print "fileName = "; fileName
LiveFileBrowser = CreateURLTransferObject(fileName)
LiveFileStatus = LiveFileBrowser.Head()
if( "200" = tostr(LiveFileStatus.GetResponseCode()) OR "304" = tostr(LiveFileStatus.GetResponseCode()))
return true
else
return false
end if
else
return false
end if
End Function
The script runs and gets to the line:
LiveFileBrowser = CreateURLTransferObject(fileName)
Once it reaches this line I get an error stating:
Function Call Operator ( ) attempted on non-function. (runtime error &he0) in pk
g:/source/loaddata.brs(519)"
The filename is read from an xml file, it is not just a name but a url path to my server like:
http://xxx.xxx.x.xxx:8000/video/first.xmlFrom what I can tell from the error message, it thinks CreatURLTransferObect is a function and fileName is trying to be passed to it, but it does not like it for some reason. What am I missing?
Thanks