Android Question B4X classes structure question

Midimaster

Active Member
Licensed User
From my former used basic dialect I knowed classes with GLOBALs variables and FIELDs variables.
The GLOBALs kept f.e. LISTs of instances or were parameters that were unique for all instances of the class. A...
B4X:
GLOBAL limit as INT=4
meant, that all instances could read this value as 4 immediately. And if one instance changed it, the others could read the new value.

The FIELDs contained variables only existed inside an instance.
B4X:
FIELD x as INT
Each instance had its own X. If the instance changed the value, this did not affect the X of other instances.

The same with SUBs. The former basic dialect knowed FUNCTIONs and METHODEs.
The FUNCTIONs could be called without having any instance yet. F.e. to create a NEW instance or to iterate through all instances of a class.

The METHODEs could be called only from an existing instance.

As I understand, B4X-dialect variables are similar to FIELDs for variables, and subs are similar to METHODEs .

But do I have also the other access? something like GLOBALs or FUNCTIONs ?

And the former basic dialect had a NEW keyword to create a new instance. There is nothing similar in B4X?
 
Last edited:

agraham

Expert
Licensed User
Longtime User
GLOBAL = Static variable : n/a for a class - use Process_Globals of an Activity or Service, or a code module
FIELD= Instance variable : class Sub Globals Public items
FUNCTION = Static method : n/a for a class, use a code module
METHOD = Instance method : class Public Subs
NEW = Create instance : Dim
 
Upvote 0
Top