PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Condition parameter
  • Configuration keyword
  • ConfigurationType keyword
  • Compilations according to the type of strings used (UNICODE or ANSI)
  • Benefits and limitations
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Compilation statement: COMPILE IF
In french: COMPILE SI
The <COMPILE IF> statement allows you to compile (or not) a WLanguage code according to a condition.
This statement is mainly used to easily get a multi-configuration code, without displaying any compilation errors (using Configuration and ConfigurationType).
Difference between <COMPILE IF> and the conditional target-code:
  • The conditional target-code compiles the code.
    The conditional target-code is interesting for a component that will be run on different platforms for example. The code is compiled in all the platforms and it will be run according to the current platform. See Conditional target-code for more details.
  • The conditional compilation (<COMPILE IF> statement) does not compile the code. It is mainly used to avoid displaying the compilation errors (using Configuration and ConfigurationType). See Benefits and limitations for more details.
Example
<COMPILE IF Configuration <> "Java archive">
Trace("No Java archive")
<END>
<COMPILE IF Configuration <> "Java archive" AND Configuration = "Windows 32-bit executable">
Trace("No Java archive and Exe32")
<END>
<COMPILE IF Configuration = "Linux64" OR ConfigurationType = Android>
Trace("Linux64")
i is int = 12
<ELSE>
Trace("Other")
i is string = 24
<END>


Trace("i = " + i)
// Declare a constant whose value depends on the configuration
<COMPILE IF Configuration <> "Java archive">
CONSTANT
Constant_Name = 10
   END
<ELSE>
CONSTANT
Constant_Name = 20
   END
<END>
Syntax

Compilation according to a condition

<COMPILE IF <Condition>>
... // Code compiled if the condition is true
<END>

Compiling a code or another one according to a condition

<COMPILE IF <Condition>>
... // Code compiled if the condition is true
<ELSE>
... // Code compiled if the condition is false
<END>

Compiling a code or another one according to several conditions

<COMPILE IF <Condition1>>
... // Code compiled if <Condition1> is true
<SINON IF <Condition2>>
... // Code compiled if <Condition2> is true
...
<SINON IF <ConditionN>>
... // Code compiled if <ConditionN> is true
<END>

Compiling a code or another one according to several conditions

<COMPILE IF <Condition1>>
... // code compiled if <Condition1> is true
<SINON IF <Condition2>>
... // Code compiled if <Condition2> is true
...
<SINON IF <ConditionN>>
... // Code compiled if <ConditionN> is true
<ELSE>
... // Code compiled if all the conditions are false
<END>
Versions 22 and later

Compiling a code according to the types of strings used

<COMPILE IF ANSIConfiguration/UNICODEConfiguration>
... // code compiled if the current configuration is using ANSI strings or UNICODE strings
<END>
New in version 22

Compiling a code according to the types of strings used

<COMPILE IF ANSIConfiguration/UNICODEConfiguration>
... // code compiled if the current configuration is using ANSI strings or UNICODE strings
<END>

Compiling a code according to the types of strings used

<COMPILE IF ANSIConfiguration/UNICODEConfiguration>
... // code compiled if the current configuration is using ANSI strings or UNICODE strings
<END>
Remarks

Condition parameter

The condition must be evaluated during the compilation: therefore, it can only contain literal elements (numbers, strings, True, False, ...) or constants.
Notes:
  • No function can be used in the condition.
  • The condition can use comparison operators.
  • Specific keywords can be used: Configuration and ConfigurationType.

Configuration keyword

The Configuration keyword returns the name of the current configuration. Therefore, you have the ability to write:
<COMPILE If Configuration = "TestConfig">
// Code compiled in the "TestConfig" configuration
<END>

ConfigurationType keyword

ConfigurationType returns the type of the current configuration. Therefore, you have the ability to write:
<COMPILE IF ConfigurationType=WindowsApplication>
// Code compiled in all the Windows configurations
<END>
The available types of configuration are:
  • WindowsApplication
  • Windows32Application
  • Windows64Application
  • Site
  • Library
  • ExternalComponent
  • Webservice
  • DotNetAssembly
  • DotNetApplication
  • Java
  • LinuxApplication
  • Linux32Application
  • Linux64Application
  • RADPattern
  • WindowsService
  • Windows32Service
  • Windows64Service
  • LinuxService
  • Linux32Service
  • Linux64Service
  • Android
  • ActionPlan
  • iOS
  • MacOSX
  • UniversalWindowsApp
  • WindowsMobile
Versions 22 and later

Compilations according to the type of strings used (UNICODE or ANSI)

The syntax that is using the ANSIConfiguration and UNICODEConfiguration keywords is used to compile a code according to the type of strings used.
This parameter is defined in the description window of the current configuration ("Unicode" tab).
Defining the format of strings
New in version 22

Compilations according to the type of strings used (UNICODE or ANSI)

The syntax that is using the ANSIConfiguration and UNICODEConfiguration keywords is used to compile a code according to the type of strings used.
This parameter is defined in the description window of the current configuration ("Unicode" tab).
Defining the format of strings

Compilations according to the type of strings used (UNICODE or ANSI)

The syntax that is using the ANSIConfiguration and UNICODEConfiguration keywords is used to compile a code according to the type of strings used.
This parameter is defined in the description window of the current configuration ("Unicode" tab).
Defining the format of strings

Benefits and limitations

If the conditions specified in <COMPILE IF> are not fulfilled, the WLanguage code is not compiled. The non-compiled code is displayed in gray in the code editor, with a minimum formatting.
Benefits:
  • There is no compilation error: the features specific to each platform (Android, iOS) can be coded without triggering any compilation error in the other configurations.
  • The same variable can be declared in the two parts of a compilation condition with different types.
Limitations: In the non-compiled code:
  • no assisted code input is available.
  • no cross-reference is available: no Shift+F2, the uses of elements are not displayed, the elements can appear in the list of orphan elements and dead code.
  • there is no code analysis: no smart renaming.
  • there is no compilation error: if the prototype of a procedure is modified, the error will be displayed when using a configuration that allows the code compilation.
Minimum version required
  • Version 21
This page is also available for…
Comments
Click [Add] to post a comment