Wish Variables in #PackagerProperty, #CustomBuildAction, & #Macro

Chris2

Well-Known Member
Licensed User
Longtime User
[please correct me if this already exists!]
I wish we could use user definied variables in #PackagerProperty, #CustomBuildAction, & #Macro, and date variables specifically in #PackagerProperty?

I realise that we can use Environment Variables, date variables, etc already in #Macro declarations like:
B4X:
#Macro: Title, ExportAsZip, ide://run?File=%ADDITIONAL%\ZipperWm.jar&Args=|target|%PROJECT_NAME%_V2.00_%YYYY%-%MM%-%DD%.zip|targetdir|D:\B4J\AppBackup\
[note that as per @walt61's post #2, the %YYYY%-%MM%-%DD% in the above is in the args of ZipperWm. These are not handled by the IDE #Macro handling itself]

But, so far as I can tell we can not:
1. Use the same variables in #PackagerProperty items
2. Use user defined variables in any of #PackagerProperty, #CustomBuildAction, or #Macro

What I would specifically like to be able to do is something like the following, mainly so that the app version and dates don't need to be updated in multiple areas:
B4X:
Public const FullAppVersion As String = 2.0.0.0
Public const ShortAppVersion As String = 2.00


#PackagerProperty: AssemblyVersion = %FullAppVersion%
#PackagerProperty: AssemblyCopyrightAttribute = Copyright (c) %YYYY%, My Company

#CustomBuildAction: After Packager, D:\SomeOtherApp\OtherApp.exe, %PROJECT_NAME% %FullAppVersion%

#Macro: Title, ExportAsZip, ide://run?File=%ADDITIONAL%\ZipperWm.jar&Args=|target|%PROJECT_NAME%_V%ShortAppVersion%_%YYYY%-%MM%-%DD%.zip|targetdir|D:\B4J\AppBackup\


UPDATE: as per @walt61's post #2, I was wrong to think that date variables are handled by the IDE in #Macro. So the wish is actually for date varaibes and user defined variables to be handled by the IDE in all of #PackagerProperty, #CustomBuildAction, & #Macro.

Thanks.
 
Last edited:

Chris2

Well-Known Member
Licensed User
Longtime User
@Chris2 : note that in ZipperWm, I do the substitutions for the date and time variables in the code; these ones don't come from the IDE.
Ah yes, I should have spotted that they were in the args. I'll update the description of the wish.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is a good idea.
I'm sharing a tip that can be useful for some similar cases.
You can create a batch file that sets environment variables and then start the IDE:
For example:
B4X:
set YEAR=2026
start "" "C:\Program Files\Anywhere Software\B4A\B4A.exe"

You can then use this env variable (in places where it is supported0:
B4X:
#Macro: Title, Export B4XPages, ide://run?File=%B4X%\Zipper.jar&Args=%PROJECT_NAME%_%YEAR%.zip

This is not really suitable for dates as it will not be updated until the IDE is restarted. It can be useful for paths or passwords.
 
Top