Wish List - Include Files

SeaCay

Member
Licensed User
Longtime User
Hello Erel et Al

I am maintaining several apps where there are several blocks of common code. A change to any of the apps within the common code blocks needs to be reflected and maintained in all 8 other apps. Forgetfullness on my part is highlighted when the other unchanged apps are recompiled. In order to overcome this problem, I would like to have the ability to include files dynamically into code.

Such as (Delphi style as example only)

{$Include 'MyConstants.inc'}

For the above I might have code

B4X:
Dim kount as Int
Dim genMsg as string
{$include 'MyConstants.inc'}
Dim SentinelValue as int = -1

The file MyConstants.inc would contain code that was compatible with the point where the include is located in the code body.

I am not sure if this has been requested before but if so, it has my support.

regards and thanks

SeaCay
 

sorex

Expert
Licensed User
Longtime User
I think this was discussed before so we got the option to use these code modules which can be compared to inserts in some way (altho you always need to feed the views as parameter as it can't 'reach' it otherwise)

Copying/modifying the code of classes and modules in every project folder is boring.

I think it's the most safe thing to do since you tweak most of the code for a new project so that it suits the best (at least I do most of the time)
so your other ones will give issues if you do this with a plain include like include("c:\sources\includes\myinclude.inc")
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
I've just been looking at the compile as library for some of my utility modules. I think I'll go a long way towards what you want. Take a look if you haven't already.
 

rico456

New Member
I'm surprising this function not exist, she's present in so numerous other languages. :(
Furthermore she simplify so much the code, and adding an important function already missing in JAVA
 
Last edited:

rico456

New Member
Thanks EREL for your quick answer :cool:
And excuse me for my bad english
The value of a language is also the time for have a good answer to a beginner problem

After your answer, i have try the sharedModule, and see with pleasure it possible to enter a relative path, and that works, it's cool
Because i always works on an external hard drive, and too much language not allow this

The only problem with your method against IncludeFile, it's when you want cut the source in several piece for better visibilitty
Not really shared code between projects, just manage the code for one project.

With IncludeFile it's possible, we can use all the .bas wanted, present in a folder, without shared it

I'm happy to see this option exist, because i have lost one day to search a method for move the event on several class
Thanks to Informatix, i have found this
https://www.b4x.com/android/forum/threads/include-files.34442/#post-201872
But one time more, it's not also cool than IncludeFile
 
Last edited:
Top