Wish Truly global variables and subs.

Tom_707

Member
Licensed User
Is it possible to implement truly global variables and subs? ie. Variables and subs that can be called from any other module, without having to prefix their names with the name of the module they were defined in.

So instead of having to use Main.Variable1 or Main.Sub1, you can just use Variable1 and Sub1 in any module.

Is this something that would be difficult to implement? Or is it the way that the Android architecture operates, that prevents a feature like this from being implemented?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is this something that would be difficult to implement?
Not trivial but possible.

Or is it the way that the Android architecture operates, that prevents a feature like this from being implemented?
B4X programming language features have nothing to do with Android architecture.

Will it be added? Probably no.
I think that the benefits of such feature are minimal and are only relevant to small projects.
 

Midimaster

Active Member
Licensed User
Why not this way:
Let say a BAS module is a only outsourced text parts of the main module.
The users can divide a too long code into different text snipplet. Each shown in a separate TAB.
Or the use can outsource text-parts, which already contain 100% error free code.
Now the compiler could re-import them into one big main module before start the compiling. In this moment they all are one file.

This needs no change in the compiler. Classes would not be touched by this. Ok, you would have to do a lot in adjusting your Auto-Syntax-Control.
I know this from my old basic dialect
B4X:
#Import Standard.bas
#Import Record.bas
#Import ConstDef.bas
#Import LoadResources.bas
...

This would also give us the chance to close TABs with code we do not edit at the moment, but of course should stay in the project.
 

a6000000

Member
Licensed User
Longtime User
at the moment you can simulate this in one file, with folding with #region

#region Import standard.bas
..the code
#End Region

#region Import Record.bas
..the code
#End Region

#region Import ConstDef.bas
..the code
#End Region

' and for comment folding sam multiline text help coment or note use:
#Region Txt note comment 1
#If txttxtnote12
note12
#End If

#If txttxtnote13
note13
#End If
#End Region



and, if nesessary, find the region in the search and in the tab: Modules
 
Top