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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rsromeo
Channel Surfer

RUNNING A REMOTE SCRIPT

Can someone please clue me in on how I would go about calling and running a remote BRS script. I tried RUN but it only works running another script from within the package. I need to run a remote script from a URL. The remote script has special functions that I will need to update occasionally which is why I want to keep it remote rather than include it with the package. Thanks for your help.
0 Kudos
10 REPLIES 10
TheEndless
Channel Surfer

Re: RUNNING A REMOTE SCRIPT

"rsromeo" wrote:
Can someone please clue me in on how I would go about calling and running a remote BRS script. I tried RUN but it only works running another script from within the package. I need to run a remote script from a URL. The remote script has special functions that I will need to update occasionally which is why I want to keep it remote rather than include it with the package. Thanks for your help.

I haven't tried it, but it seems like it should work... have you tried doing roUrlTransfer.GetToFile() to a "tmp:/" path and running that?
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)
0 Kudos
kbenson
Visitor

Re: RUNNING A REMOTE SCRIPT

Indeed, you can download files into tmp and run from there. I've tested this quite a bit.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
rsromeo
Channel Surfer

Re: RUNNING A REMOTE SCRIPT

thanks. I tried it but it doesn't seem to run the remote script. does the remote script need to be formatted a special way? It is a .brs file that contains an roList. Here's what I tried doing...

var = CreateObject("roUrlTransfer")
var.SetUrl("http://website.com/test.brs")
var.GetToFile("tmp:/test.brs")

Then I tried both Run and Eval but neither seems to work.
Eval("tmp:/test.brs")
Run("tmp:/test.brs")
0 Kudos
TheEndless
Channel Surfer

Re: RUNNING A REMOTE SCRIPT

Have you checked GetLastRunCompileError() and GetLastRunRuntimeError() to see if your script is producing errors?
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)
0 Kudos
rsromeo
Channel Surfer

Re: RUNNING A REMOTE SCRIPT

yes. actually in the debugger, looks like Run is running the script but the error I get says

/tmp/plugin/FABAAAmzGSZ1/tmp:/test.brs(64): runtime error ec: 'Dot' Operator attempted with invalid BrightScript Component or interface reference.

In remote script, I am making reference to an object in the calling script which is why I think I'm getting the error. My remote script looks something like this...

list = CreateObject("roList")
list.AddTail("abc")
list.AddTail("123")
list.ResetIndex()
x= list.GetIndex()
while x <> invalid
if show.Title = x then
screen.AddButton(2, "test")
end if
x = list.GetIndex()
end while

The error is on the line that says (if show.Title). "show" is an object in the calling script. how can I make the calling script and remote script interact with each other so the variables are recognized in each?
0 Kudos
rsromeo
Channel Surfer

Re: RUNNING A REMOTE SCRIPT

does the script being called need to have Main() ?
0 Kudos
TheEndless
Channel Surfer

Re: RUNNING A REMOTE SCRIPT

"rsromeo" wrote:
The error is on the line that says (if show.Title). "show" is an object in the calling script. how can I make the calling script and remote script interact with each other so the variables are recognized in each?

According to the SDK documentation, the Run function takes optional arguments that can be passed to the scripts Main() function.

"rsromeo" wrote:
does the script being called need to have Main() ?

I believe with Run() it does. Optionally, you could do a GetToString() and Eval() the result, which I'm pretty sure uses the context of the running script.
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)
0 Kudos
rsromeo
Channel Surfer

Re: RUNNING A REMOTE SCRIPT

thank you all for your help, especiallyTheEndless - you rock!!! Used GetToString() and Eval() and IT WORKS!!! thanks again!! 🙂
0 Kudos
kbenson
Visitor

Re: RUNNING A REMOTE SCRIPT

"rsromeo" wrote:
yes. actually in the debugger, looks like Run is running the script but the error I get says

/tmp/plugin/FABAAAmzGSZ1/tmp:/test.brs(64): runtime error ec: 'Dot' Operator attempted with invalid BrightScript Component or interface reference.

In remote script, I am making reference to an object in the calling script which is why I think I'm getting the error. My remote script looks something like this...

list = CreateObject("roList")
list.AddTail("abc")
list.AddTail("123")
list.ResetIndex()
x= list.GetIndex()
while x <> invalid
if show.Title = x then
screen.AddButton(2, "test")
end if
x = list.GetIndex()
end while

The error is on the line that says (if show.Title). "show" is an object in the calling script. how can I make the calling script and remote script interact with each other so the variables are recognized in each?


Unless you are testing method equivalence (not return value), shouldn't that be "show.Title()" instead of "show.Title"?

My original testing on this was to convert an existing app of mine to be entirely loaded from the network. To do so, I changed references to files shipped with it tmp:/ paths, and in the initialization routine for it, had it download and store the files in tmp:/. After that, which still works as a standalone app, I simply had a small 10-20 line app that downloaded the script files and did a Run() on them. Think of it as identical to sideloading your app (needs a main, etc) except you have to use tmp:/ for files and either download them to tmp:/ ahead of time or within the downloaded code. If you think of it that way, it's fairly easy to debug using the normal sideloading process, and then switch to downloaded code after most the bugs have been worked out.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos