I have several B4A apps that are part of a larger project. They are all related and share code modules, custom views etc.. Each B4A app is in a separate directory because many of them are test apps and the code won't be shipped with the final project.
The main app is called App1 and in its Starter.bas file defines the global types, global variables, the SQL variable etc and it works fine. There is just under 100 lines of (sparse) code (mostly type & variable definitions) in this Starter.bas file. App1 runs just fine.
Here is the problem. Since my code modules reference these global variables and types from App1's Starter.bas, how do I get my other B4A apps like App2 that is related to this project, be able to use the same code modules that reference the global variables and types that are defined in Starter.bas of App1? App1 and App2 are in 2 different directories.
Some solutions:
- I don't want to copy and paste App1's Starter.bas into App2's Starter.bas because it will be too difficult to maintain.
- B4A does not have the ability to use Include files so I can't share the code between apps.
- Do I remove the App2 Starter.bas from the project and then select Project > Add Existing Module and select App1's Starter.bas that is in App1's directory?
- Do I have an empty Starter.bas for each app and have its Starter.Process_Globals sub call GlobalVars.Init which is a sub in a code module called GlobalVars.bas that defines the global types and variables that are defined in its GlobalVars.Process_Globals sub? Will that work? In other words, will Starter.bas be able to reference the variables and types defined in GlobalVar.Process_Global as if it was its own?
Will one of these options work, or is there a better way?
TIA