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

Referencing a function from a brs file from another brs file?

What is the best way for one BRS file (that does not have an associated XML file) to reference a function within another BRS file (that does have an associated XML file)?
0 Kudos
6 REPLIES 6
EnTerr
Roku Guru

Re: Referencing a function from a brs file from another brs file?

There is no "best way". It either works or it doesn't 🙂
Be more specific!
The typical Brightscript behavior is that all files in /source are included automatically and visible (i.e. the main thread).
In XMLophony though, only the explicitly <script> included sources are visible.
0 Kudos
jaxim
Visitor

Re: Referencing a function from a brs file from another brs file?

In A.brs file (located under the folder: "/components/screens/A), I have the following function: 
Function foo()
  ? 'foo()$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
end Function


In a different file (B.brs located under the folder "/source"), I try to make reference to the foo() method like so:
foo()


But this causes a runtime error.

What am I doing wrong? How do I ensure the B.brs file has a reference to the A.brs file.
0 Kudos
softworkz
Visitor

Re: Referencing a function from a brs file from another brs file?

You need to put an additional <script> tag into your component xml file
0 Kudos
jaxim
Visitor

Re: Referencing a function from a brs file from another brs file?

But I want to make a reference from B to A. B does not have a corresponding XML file.
0 Kudos
EnTerr
Roku Guru

Re: Referencing a function from a brs file from another brs file?

"jaxim" wrote:
But I want to make a reference from B to A. B does not have a corresponding XML file.

Who is executing or including the B file?
If the functions in B.brs are executed as part of main() thread, so should A.brs file be part of /source.

Yes, the mating between RSG and  Brightscript has been grossly mismanaged (or "fork"ed up, if you will)... but we all knew that already.
0 Kudos
KiranPrasanna
Channel Surfer

Re: Referencing a function from a brs file from another brs file?

I have two brs files i.e task.brs and grid.brs 

I have set the variable value in task.brs file. I need to access this variabel value in grid.brs file . But I don't know how access that value. Could you provide the information

0 Kudos