Name

$IfOpt Compiler Directive

Syntax

{$IfOpt Switch+}
   ...
{$Endif}
{$IfOpt Switch-}
   ...
{$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
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset