iOS Question Reusing B4A activity Module code

iCAB

Well-Known Member
Licensed User
Longtime User
Hi All

I am wondering if there is a way to reuse B4A activity code modules with B4I (without having to create a new file). In theory, if I am not mistaken the only difference is in the file header and the rest can be done using
#if B4A etc..
Can someone please comment on this

Thank you
 

iCAB

Well-Known Member
Licensed User
Longtime User
It is not recommended. They will be converted to regular static code modules when they are saved from B4i.

Erel, do you see any issue in creating a utility that changes the header information in the .bas file.
This will allow reusing the activity module as static code module with B4I, and change it back to an activity module later on as needed.

For example: Change this

B4X:
Type=Activity
Version=5.2
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

to

B4X:
Type=StaticCode
Version=1.21
ModulesStructureVersion=1
B4i=true
@EndOfDesignText@
'Code module

and remove the Globals Section (move to Process_Globals)

Is there more to it, than this?

Thanks again
 
Last edited:
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Did you find any issues with doing this iCAB?
It sounds like a great workaround, just a pity the switching can't be done with #if B4a and #if B4i conditional compilation.

I had to play around a bit with the directives. But it is working perfectly ok for me.
I am reusing the same code as is with the help of NotePad++ ( search and replace ), and most likely soon enough I will write a small utility that does this.
 
Last edited:
Upvote 0

affable

Member
Licensed User
Longtime User
I had to play around a bit with the directives. But it is working perfectly ok for me.

Thanks iCAB. I have also got it working, however I discovered you can't even leave a space after the "Type=StaticCode" or it will not work.
I include the "find & replace" tips right near the top of the code in comments so I can remember what to swap for b4a and b4i. Only 4 files so its more of a nuisance than time consuming.
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Thanks iCAB. I have also got it working, however I discovered you can't even leave a space after the "Type=StaticCode" or it will not work

I am glad you did get it to work. The biggest challenge for me was not related to search and replace, but instead it was the program flow and variables life cycle.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…