Wish Add New Module: Cross-platform

Cadenzo

Active Member
Licensed User
Longtime User
Really great, how much code we can already share between B4A, B4i and B4J, very good explained in B4X Cross-platform projects. But each new Page / Form / Activity needs two new modules. Wouldn't it save time, if we can choose Project / Add New Module / "Cross-platform"?

Let's say, we choose the name "Screen2", all the code (in B4A case) could be already done::
Sub Process_Globals

End Sub

Sub Globals
Private xMe As xScreen2
End Sub

Sub Activity_Create(FirstTime As Boolean) 'We don't load the layout here, but in the shared class
'Activity.LoadLayout("Layout1")
  If xMe.IsInitialized = False Then
   xMe.Initialize(Activity)
  End If
  xMe.Show
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause(UserClosed As Boolean)
  Activity.Finish
End Sub

If the Class xSceen2 is not existing yet, it will be created (in the shared folder) with every default settings like defining the xui object and the Sub Initialize.

Another detail:
In the docu it is recommed to use names like Screen2 and xScreen2. But in my opinion it would be better to use something like Screen2 and Screen2Class or Screen2Shared , because it would be in a perfect alphabetical order in the IDE Modules list.
 
Last edited:

Cadenzo

Active Member
Licensed User
Longtime User
Or another way to solve it already in the compiler: Every class or code module can be combined with a equal named file in a defined shared folder, if exists. So in our case there would be also a file "Screen2" in a shared folder. No need to define extra shared classes.
 

Alexander Stolte

Expert
Licensed User
Longtime User
A better implementation would be a CrossPlatform Activity module like this one:
 

klaus

Expert
Licensed User
Longtime User
In the docu it is recommed to use names like Screen2 and xScreen2.
I'm afraid that you misunderstood this!
It is not a recommendation but a suggestion.
You can define whatever you want.
I found it easy to use names like this:
Main, xMain, Edit, xEdit, Filter, xFilter like in the B4X_SQLiteLight2 example project in the same booklet.
The platform specific module with a meaningful name and then the cross-platform module with the same name but an 'x' before.
But, that's just my feeling, which I put in the documentation, simple and efficient in my opinion.
It depends on your preferences.

Do you prefer: This
1591723423428.png
or this
1591723491134.png
?

Anyway, it's your choice.

Wouldn't it save time, if we can choose Project / Add New Module / "Cross-platform"?
This is already the case in latest B4J and B4A versions, and will be the case for B4i the next update.
When you save the module, you are asked for the module name, here you can check
1591722077773.png
to save it in the parent folder for cross-platform projects.

1591722038978.png

This is a copy from the B4J 8.30 IDE and it is already in the, not yet updated, booklet.
 
Last edited:

Cadenzo

Active Member
Licensed User
Longtime User
you can check
1591722077773.png
to save it in the parent folder
This are good news, that also can save time. One wish a day is enough, so I will not open a new one, but why not file / "Save as template" and than choose also templates in a ComboBox beside the module name and "parent folder" option?
 
Top