Topic Path: Symbol Reference > Functions > iif Function (Boolean, string, string)
iif Function

Derives a return value based on a conditional expression.

function iif(
    ATest: Boolean; 
    const ATrue: string; 
    const AFalse: string = ''
): string; overload;
Conditional expression to be tested.
Value to return when the expression is True.
Value to return when the expression is False. 

String - Return value for the evaluated conditional expression.

iif is a utility function that emulates the ternary operator found in C, C++, C#, and Java. 

iif is an overloaded function that provides return values specified in ATrue and AFalse based on the conditional test expression in ATest. When ATest evaluates to True, then the return value in ATrue is used. When ATest evaluates to False, then return value in AFalse is used. 

iif is overloaded to allow use of Integer, String, and Boolean return values.

  sResult := iif(bCondition, 'True', 'False');
  iResult := iif(bCondition, 1, 0);
  bResult := iif(bCondition, True, False);
Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.