Search code examples
brightscript

Roku app main function and execution process


I'm new to roku development and just had a few questions regarding the code and file structure and the execution process at runtime:

  1. How does file linking work? I've had a look at some of the example apps, some contain multiple files but I can't see a clear way of how they files are linked or functions are imported.
  2. Is there a base script and function that sets everything off? Some apps use Sub Main but some don't; how does the platform know where the app's start point is?

Solution

  • All files within a project ending with .brs are linked as if they were in the same file.

    A program will start with sub or function main() or runuserInterface(), or for screensavers, runscreensaver()

    Libraries can be imported with the library command which needs to exist outside of any function or sub.

    See here: http://sdkdocs.roku.com/display/RokuSDKv48/BrightScript+Language+Reference#BrightScriptLanguageReference-412ScriptLibraries