Name
$IfOpt Compiler Directive
Syntax
{$IfOptSwitch
+} ... {$Endif} {$IfOptSwitch
-} ... {$Endif}
Scope
Local
Description
$IfOpt
is similar
to $IfDef
, except that it tests the state of a
switch compiler directive. Only single-letter switches can be tested.
If the directive is enabled, the
Switch
+
test is True
and Switch
-
is False.
If the directive is disabled,
Switch
+
is False and
Switch
-
is
True.
See $IfDef
for more information.
Example
// Temporarily disable Range checks, then revert to the original switch. {$IfOpt R+} {$define RangeChecks} {$else} {$undef RangeChecks} {$endif} {$R-} ... // code that requires range checks be disabled {$ifdef RangeChecks} {$R+} {$endif}
See Also
$Define Compiler Directive, $Else Compiler Directive, $Endif Compiler Directive, $IfDef Compiler Directive, $IfNDef Compiler Directive, $Undef Compiler Directive |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.