Forum Discussion
floatleftintera
10 years agoVisitor
to avoid using functions within an inline <script> tag you can include a separate file for a component's sub init(). For shared or common functions like utility functions you can include another <script> tag and these functions will work within the scope of that component as well as any other component that includes it.
Example
source/utils/string.brs has:
function tokenize() as object
component A includes its component script, at pkg:/components/component_a.brs and includes a tag with pkg:/source/utils/string.brs
component B includes its own script, pkg:/components/component_b.brs and pkg:/source/utils/string.brs
both components can use tokenize() within their own scope. At runtime scripts from components/ do not conflict with each other while scripts in source/ would.
Example
source/utils/string.brs has:
function tokenize() as object
component A includes its component script, at pkg:/components/component_a.brs and includes a tag with pkg:/source/utils/string.brs
component B includes its own script, pkg:/components/component_b.brs and pkg:/source/utils/string.brs
both components can use tokenize() within their own scope. At runtime scripts from components/ do not conflict with each other while scripts in source/ would.