Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
neowinston
Level 7

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
joetesta
Level 10

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
Roku Employee
Roku Employee

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
Level 7

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

Thanks for the help Joe and RokuNB!
0 Kudos