Code modules...

skipsy

Member
Licensed User
Longtime User
Hello,

I was wondering if it is possible to add part of code using something like
<include "xxx">
For Ex :
B4X:
Sub Activity_Create(FirstTime As Boolean)
  <include "player_initialisation.bas">
  <include "balls_initialisation.bas">
  
End Sub

Sub timer1_Tick
  <include "manage_balls.bas">
  etc...
End Sub
The goal is to have the main program smaller.

Or... Is there a way to collapse/expand part of the code (like for subs) ?

I read in the "beginner's guide" and "B4A Tutorial" that I can use the
modules but this is not the same and this is supposed to declare ALL
VARIABLES in Process_Globals sub. So Erel wrote :
Process variables -
NOT ALL TYPE of objects can be declared as process variables.
All of the views for example cannot be declared as process variables.
The reason is that we do not want to hold a reference to objects that should be destroyed together with the activity....

Is there anything I misunderstood ??

Thank you,
William.
 

joseluis

Active Member
Licensed User
Longtime User
1) You can use code modules and you can there define process_global variables and any subs you want.

2) You can also use collapsable regions . (By the way, that thread is very handy for newcomers)

3) The variables that holds references to views in the activity, if you want them to be global then they must be declared in sub Globals. But they are only global to that module, not accesible from other modules.

Read this thread: 6487-android-process-activities-life-cycle
 
Upvote 0

skipsy

Member
Licensed User
Longtime User
Thank you Joseluis,

#region / #End region : This is exactly what I was looking for.
Where did you find this info ?
I did a "find" in the Beginners guide.pdf, in B4A_tutorials.pdf and also the
IDE tips in the IDE help menu... but found nothing talking about REGIONS

Best regards,
WW
 
Upvote 0
Top