Tool Conditional compiling for B4A

Because Basic4android supports currently no conditional compilation, i have written a small utility for this.

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

  • B4Aconditioner_1.1.zip
    509 KB · Views: 204
  • B4Jconditioner_1.1.zip
    499.9 KB · Views: 184
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Yes. How get i the program running? ;)

If i start it directly it shows me an alterbox saying that it should be started with
B4Aconditioner project
or
B4Aconditioner projectfolder (genaugenommen ist das ja eine Deutsche Fehlermeldung (Aufruf: B4Aconditioner b4a_project|b4a_projektordner) :D)

If i want to drag a project-file or s projectfolder to it then nothing happens...

Anyway: THANK YOU for sharing this Tool. It would be REALY interesting to have such a tool! A lot of new possibilities comes out with this! :)
 

MaFu

Well-Known Member
Licensed User
Longtime User
Yes. How get i the program running? ;)

If i start it directly it shows me an alterbox saying that it should be started with
B4Aconditioner project
or
B4Aconditioner projectfolder (genaugenommen ist das ja eine Deutsche Fehlermeldung (Aufruf: B4Aconditioner b4a_project|b4a_projektordner) :D)

If i want to drag a project-file or s projectfolder to it then nothing happens...

Anyway: THANK YOU for sharing this Tool. It would be REALY interesting to have such a tool! A lot of new possibilities comes out with this! :)

If you drag a project folder on it, all b4a and bas files in this folder are processed and the program ends immediately without message.
Nothing happens if you have no keywords in your files. You must set the keywords ({DEFINE XYZ}, {IFDEF XYZ}, ...) for yourself and then process the project with B4Aconditioner before compiling.
Have you tried the test project? Have a look at the files in the test project, process it with B4Aconditioner and then look again.
 

DonManfred

Expert
Licensed User
Longtime User
Soory, its my mistake then ;-)
I hinked that something comes out to see. I espected an editor or such things. It did not realiced that it could be an CLI-Program. My mistake. Will make some tests tomorrow... For today i´m busy.

Today is the Fleedwood Mac world Tour 2013 Concert in Cologne. :D
 
Last edited:
Top