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?
1. Nothing special needs to be done to use multiple files. All .brs files in your source directory are compiled together. 2. The entry point is RunUserInterface. If there is no such function, it uses Main. If the channel has a screensaver, there are one or two special entry points, RunScreenSaver to run the screen saver, and RunScreenSaverSettings to run the settings screen for the screen saver, if there is one.
"btray77" wrote: No MVC or MCCM examples.. The language isn't really setup to easily do that, but you can abstract some of the "view" aspects away using XML and reading it in and determining what goes where.
Ok, is it then possible to organise my code within folder under the `source` folder? Or do all the code files have to be at the top level in order to be loaded by the interpreter?
You can organize your .brs files within your project any way you want, source in any .brs file within your project should be compiled the same as if it was all in one .brs file. You can have folders within the source folder containing .brs files and folders within those folders. Not sure how deep you can go with that, and too many might slow down the compilation process. I've found that breaking a project up into a large number of .brs files does not compress as well as just a few .brs files, but storing all code within one .brs file doesn't compress that well either when you zip it.