Android Tutorial Shared Code Modules

Erel

Administrator
Staff member
Licensed User
Edit: shared modules are still supported however more powerful options are available in newer versions of B4X: https://www.b4x.com/android/forum/threads/86587

B4A v3.80 adds support for shared code modules.
Shared code modules are modules (Activity, Service, Class or Static Code) that are stored in a specific folder and can be shared by multiple projects, similar to the way that libraries are shared.

How it works

When a project is loaded the IDE looks for the modules files (bas files) in the project folder. If the module file doesn't exist then the IDE will look for the module in the configured shared modules folder.

The shared modules folder is set in the Paths Configuration dialog:



You can see that a module was loaded from the shared folder in the list of modules (the icon with the small arrow):



Adding a shared module to a project is done in the same way as adding a non-shared module.
You choose Project -> Add Existing Module. If the module folder is the shared folder then the module will be loaded as a shared module and will not be copied to the project folder.

If you want to convert a non-shared module to a shared module then you need to manually move the module file to the shared modules folder and reload the project
 
Last edited:

Erel

Administrator
Staff member
Licensed User
It is not shared modules vs. IDE modules. The IDE can load modules from two locations: the project folder and the new shared modules folder.

If you like to share the same code file between different projects then you should put the module file in the shared modules folder.
 

namnach

Member
Licensed User
This is very fine thinking - so "template" ( network, server, client .. ) can make for each Projects.
Thank you - !
;-)
 

klaus

Expert
Licensed User
Great Option :)
Is the same possible for .BALs ? :rolleyes:
Would be very useful !
Example:
I use a shared About module which has a dedicated bal file.
It would be very useful to share the bal file the same way as the module file.
 
Top