Here's an example:
<?xml version="1.0" encoding="utf-8" ?>
<component name="MainScene" extends="Scene" >
<script type="text/brightscript" uri="pkg:/source/main.brs" />
m.top.findNode("Number").text = somethingCalledFromSceneGraph()
Function Main(args As Dynamic) As void[/spoiler:zvqepvoo]
screen = CreateObject("roSGScreen")
scene = screen.CreateScene("MainScene")
port = CreateObject("MessagePort")
msg = wait(0, port)
Function somethingCalledFromSceneGraph() as String
return "Text from main.brs"
Just know that there are restrictions on what you can do in that function. These are documented at BrightScript Support
We should clarify what you did there is not what most people want.
Through mechanically including main.brs in the component, technically
you can call a main.brs function from the RSG thread - true. Filthy^ as it is, i imagine it can be useful occasionally (e.g. context-free utility functions like min()/max()) - but please note those are 2 separate interpreters and they do not share the global variables (getGlobalAA() / unqualified `m`) context.
(^) "ewww, RunUserInterface()/main() included too? gross!"