I’m new to roku development and just had a few questions regarding the code and file structure and the execution process at runtime:
- 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.
- 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?
Thanks! So is it safe to assume that I ought to start all apps with Sub Main function? Are there any MVC/MVVM/etc examples?
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.
“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.