UserGuide

Compilation Constants

From Xojo Documentation

Before you build your app, you choose the platform or platforms on which it will run. You can build apps for Windows, Linux, and Mac as desktop, console, web. Additionally, you can build for iOS. While programming, you can selectively enable or disable sections of your code that are valid only for particular platforms by using compilation constants.

Compilation Constants

The compilation constants tell you information about the platform on which the app is running. When used with conditional compilation you can specify blocks of source code to include or exclude for specific platforms.

These are the some of the compilation constants:

For the complete list, refer to Compiler Category.

These constants are automatically set to either True or False depending on the platform being compiled. You can use conditional compilation commands to use specific code like this:

// Saving Preferences
#If TargetWin32 Then
// Use Registry
#ElseIf TargetMacOS Then
// Use plist
#ElseIf TargetLinux Then
// Use XML
#ElseIf TargetiOS Then
// Use JSON
#EndIf

Versions

You can also check the version of Xojo being used with the XojoVersion and XojoVersionString constants. These two constants can be used to block out code that is not compatible with older (or newer versions) of Xojo.