RAD Studio (Common)
ContentsIndex
PreviousUpNext
ELSEIF (Delphi)
Type  
Conditional compilation  
Syntax  
{$ELSEIF}  

Remarks 

The $ELSEIF directive allows multi-part conditional blocks where at most one of the conditional blocks will be taken. $ELSEIF is a combination of a $ELSE and a $IF.  

For example:

{$IFDEF  foobar} 
       do_foobar 
    {$ELSEIF  RTLVersion >= 14} 
        blah 
    {$ELSEIF  somestring = 'yes'} 
        beep 
    {$ELSE} 
        last chance 
    {$IFEND} 
    

Of these four cases, only one will be taken. If none of the first three conditions is true, then the $ELSE clause will be taken. $ELSEIF must be terminated by $IFEND. $ELSEIF cannot appear after $ELSE. Conditions are evaluated top to bottom like a normal "if ... else if ... else " sequence. In the example above, if foobar is not defined, RTLVersion is 15, and somestring = 'yes', only the "blah" block will be taken not the "beep" block, even though the conditions for both are true.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!