Because Basic4android supports currently no conditional compilation, i have written a small utility for this.
The following keywords are supported:
In program code, insert the keywords as comment:
'{DEFINE DEBUG}
To disable the keyword put any character before:
'.{DEFINE DEBUG}
Keywords can be nested. Please see the sample project for precise handling.
The program handling
--------------------
For simple work, place a shortcut to B4Aconditioner on your desktop. Then drag and drop a B4A project file to the the link to edit. If a directory link is dropped, all projects therein will be edited.
First is the project file (. b4a) edited, then all the project modules (. bas). The defined terms in the project file are valid in all modules, a term defined in a module applies only in this module.
After processing all rows in the non-active sections are commented out. The comment has the format '{C} to differentiate it from regular comments.
If B4Aconditioner will be called with the parameter /REMOVE (best over an own link), then all '{C} comments will be removed.
If Basic4android is active, then before project editing it will be tested if this project is loaded in B4A. If this is the case, CTRL-S is sent to B4A first (to make sure the last change is stored) and then exits B4A. After processing, Basic4android starts again with the project.
I hope the program is a help for someone.
CAUTION: I take no responsibility for damaged files. Even if backups will be created before saving, you should perform the first tests with a copy of the project.
Update 1.1 for compatibility with Basic4Android 3.x.
And additional B4Jconditioner for B4J.
The following keywords are supported:
B4X:
{DEFINE term} Set the definition "term"
{UNDEF term} Delete the definition "term"
{IFDEF term} Test whether definition "term" is defined
{IFNDEF term} Test whether definition "term" is not defined
{ELSE} Active section, if previous test negative
{ENDIF} End of section
In program code, insert the keywords as comment:
'{DEFINE DEBUG}
To disable the keyword put any character before:
'.{DEFINE DEBUG}
Keywords can be nested. Please see the sample project for precise handling.
The program handling
--------------------
For simple work, place a shortcut to B4Aconditioner on your desktop. Then drag and drop a B4A project file to the the link to edit. If a directory link is dropped, all projects therein will be edited.
First is the project file (. b4a) edited, then all the project modules (. bas). The defined terms in the project file are valid in all modules, a term defined in a module applies only in this module.
After processing all rows in the non-active sections are commented out. The comment has the format '{C} to differentiate it from regular comments.
If B4Aconditioner will be called with the parameter /REMOVE (best over an own link), then all '{C} comments will be removed.
If Basic4android is active, then before project editing it will be tested if this project is loaded in B4A. If this is the case, CTRL-S is sent to B4A first (to make sure the last change is stored) and then exits B4A. After processing, Basic4android starts again with the project.
I hope the program is a help for someone.
CAUTION: I take no responsibility for damaged files. Even if backups will be created before saving, you should perform the first tests with a copy of the project.
Update 1.1 for compatibility with Basic4Android 3.x.
And additional B4Jconditioner for B4J.
Attachments
Last edited: