Forum Discussion

jaxim's avatar
jaxim
Visitor
9 years ago

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)?

6 Replies

  • 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.
  • 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.
    • KiranPrasanna's avatar
      KiranPrasanna
      Channel Surfer

      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

  • You need to put an additional <script> tag into your component xml file
  • But I want to make a reference from B to A. B does not have a corresponding XML 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.