After many years coding in C, I sorely miss conditional compiling as provided by #Define and #IfDef…#Else…#EndIf. This is very useful when producing two versions of a program. For example, suppose I have two versions of my masterpiece, one free and another a “pro” version with more features for which I want to be paid. Without #IfDef I would have to produce two versions of the code. If I then want to add/change something or correct a bug, I would have to maintain both versions, a recipe for trouble. I’d like to be able to include it all in one version of the code with something like:
#Define PRO 1
… #IfDef PRO
// Code for the “pro” version only #EndIf
//Code common to both versions
With this I could compile the “pro” version then delete or comment out the #Define to compile the free version.
I use App.Constants like this to set whether it is an AppStore App (or not). When I build using XojoScript, I can revise this constant many times for multiple Builds, so I don’t need to build manually.
I have a IDE Communicator and a global. I just need to adjust the version in the build script which can make one of 4 different versions of my app with helper app and everything else.
It would be great if you could include or exclude whole classes or windows with #if PRO. For example, you could exclude certain windows for a light or store version.
Today only code sections can be set with #If PRO.
Is there any interest for a feature request that besides targets also a custom constant is supported to include whole classes for specific compilation?
Perhaps, but these flags would help the compiler catch a mistake. Without the flags, if you accidentally reference an object you wanted excluded, well it gets included. With such a flag, the compiler would complain it doesn’t exist.
What’s a little frustrating is this is purely an IDE limitation. Wether or not an item is included is literally written as an #if statement. Those checkboxes essentially just build the statement for you. So including or excluding things based on platform or other constants could be done if the IDE would support it.
Well you can exclude items by turning off their platform flags on the advanced tab of the properties palette. Turning off 32 & 64 bit, for the project type you’re using does make the item get excluded.