You can use SetupSetting
preprocessor function to emit the Setup
section directive in other places of the script (Code
or not):
[Setup]
Uninstallable=no
[Code]
...
if '{#SetupSetting('Uninstallable')}' = 'yes' then ...
This results in:
if 'no' = 'yes' then ...
Related question: How to use Inno Setup preprocessor directive in [Code] section?
Though I actually find your solution better. But for type-safety and avoiding problems like case-sensitive comparison or quoted values, I'd do it like this:
#define Uninstallable false
[Setup]
Uninstallable={#Uninstallable ? "yes" : "no"}
[Code]
...
if {#Uninstallable ? 'True' : 'False'} then ...
This results in more efficient:
if False then ...
Or actually if you just want to skip whole block of code, do:
[Code]
...
#if Uninstallable
// Do something
#endif
This results in no code, when not "uninstallable", what is even more efficient and also reduces the installer size.
And then it is more common to just test for existence of the preprocessor define:
//#define Uninstallable
[Setup]
#ifndef Uninstallable
Uninstallable=no
#endif
[Code]
...
#ifdef Uninstallable
// Do something
#endif