Description |
The $IfOpt compiler directive is a meta-directive - it tests for the + or - state of a single character compiler directive.
For example:
{$IfOpt H+}
ShowMessage('Longstrings are set on');
{$EndIf}
It is useful to report on directive settings at the start of a program, when testing.
|
|
Notes |
$IfOpt can be used multiple times in your code.
|
|
Related commands |
$Define |
|
Defines a compiler directive symbol - as used by IfDef |
$Else |
|
Starts the alternate section of an IfDef or IfNDef |
$EndIf |
|
Terminates conditional code compilation |
$IfDef |
|
Executes code if a conditional symbol has been defined |
$IfNDef |
|
Executes code if a conditional symbol has not been defined |
$UnDef |
|
Undefines a compiler directive symbol - as used by IfDef |
|
|
|
Example code : Show various default directive settings |
begin // Show the default settings of various compiler directives
{$IfOpt A+}
ShowMessage('Align is On');
{$Else}
ShowMessage('Align is Off');
{$EndIf}
{$IfOpt B+}
ShowMessage('BoolEval is On');
{$Else}
ShowMessage('BoolEval is Off');
{$EndIf}
{$IfOpt H+}
ShowMessage('LongStrings is On');
{$Else}
ShowMessage('LongStrings is Off');
{$EndIf}
end;
|
Show full unit code |
Align is Off
BoolEval is Off
LongStrings is On
|
|