#If...#Else...#Endif Preprocessor Directive

Used to control conditional compilation.

Syntax

#If TargetBoolean

[statements] //OS-specific code

[#Else

[elsestatements]] // Other OS-specific code

#EndIf

The #If...#Else..#Endif directive syntax has these parts:

Part Description
TargetBoolean Required. Target_MacOS, Target_Win32 constant, used to determine the operating system that will include the code the follows.
statements Optional. One or more statements that are executed if TargetBoolean is True.
elsestatements Optional. One or more statements executed if TargetBoolean is False.

Remarks

Use conditional compilation to isolate platform-specific statements such as toolbox calls or AppleEvent routines. The code following the #If directive is included only in the build for that operating system.

Example

Dim Separator as String
#If Target_MacOS
Separator=":"
#Endif
#If Target_Win32
Separator="\"
#Endif

 

See Also