SmartPascal
$BoolEval
Compiler Directive
Whether to short cut and and or operations
1   {$BoolEval Off}
2   {$BoolEval On}
Description
The $BoolEval compiler directive tells Delphi whether to continue a multi argument boolean expression evaluation when the result is known before evaluation completes.
 
{$BoolEval Off} (default) means no continue {$BoolEval On} means continue checking
 
For example, by default, with an expression :
 
expr1 and expr2
 
expr2 is not evaluated if expr1 is false. With {$BoolEval On}, checking would have continued.
 
The example illustrates a normal use of the default.
Notes
$BoolEval is equivalent to $B.

This directive can be used multiple times within your code.

The default value is $BoolEval Off
Related commands
$B Whether to short cut and and or operations
And Boolean and or bitwise and of two arguments
If Starts a conditional expression to determine what to do next
Or Boolean or or bitwise or of two arguments
 
Example code : Checking string contents
var
  FullString, EmptyString : string;

begin
  FullString  := 'Fred';
  EmptyString := '';

  // Set full checking OFF
  {$BoolEval Off}

  // Check the 4th character of each string
  if (Length(FullString) >= 4) and (FullString[4] = 'd')
  then ShowMessage('FullString 4th character is d')
  else ShowMessage('FullString 4th character is NOT d');

  if (Length(EmptyString) >= 4) and (EmptyString[4] = 'd')
  then ShowMessage('EmptyString 4th character is d')
  else ShowMessage('EmptyString 4th character is NOT d');

  // Set full checking ON
  {$BoolEval On}

  // Check the 4th character of each string
  if (Length(FullString) >= 4) and (FullString[4] = 'd')
  then ShowMessage('FullString 4th character is d')
  else ShowMessage('FullString 4th character is NOT d');

  // Now we must protect the code from errors
  try
    if (Length(EmptyString) >= 4) and (EmptyString[4] = 'd')
    then ShowMessage('EmptyString 4th character is d')
    else ShowMessage('EmptyString 4th character is NOT d');
  except
    on E : EAccessViolation do
    ShowMessage(E.Message);
  end;

end;

Show full unit code
   The following is typical of the output from the above code:
  
   FullString 4th character is d
   EmptyString 4th character is NOT d
   FullString 4th character is d
   Access violation at address 00442196 in module
   'PROJECT1.EXE'. Read of address FFFFFFFF