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: 
neowinston
Visitor

Why I can't access a function in another file?

I'm trying to access a function in another file, but I'm getting the error:


Function Call Operator ( ) attempted on non-function. (runtime error &he0)


The function is located on the Main.brs. Even if the files are in the same folder I can't access the function. What is happening? How do I fix this? Thanks for your help! 
0 Kudos
3 REPLIES 3
joetesta
Roku Guru

Re: Why I can't access a function in another file?

usually you would have the scripts in another file (although usually not Main, not sure how that would work out)
But yes, put your function in someOtherFile.brs then include that in your component's XML and then you'll have access to that function
<script type="text/brightscript" uri="pkg:/components/someOtherFile.brs" />
aspiring
0 Kudos
NB_
Roku Guru

Re: Why I can't access a function in another file?

Brightscript source files are handled differently between SDK1 and RSG apps. The main() function and friends from pkg:/source are automatically compiled together. For RSG XML components however, only the explicitly <script uri=...> included .brs files are read for that particular component.
0 Kudos
neowinston
Visitor

Re: Why I can't access a function in another file?

Thanks for the help Joe and RokuNB!
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.