IfThen Function

woman at computer
Hero Images/Getty Images

 Declaration:

function IfThen(AValue: Boolean; const ATrue: Integer; const AFalse: Integer = 0): Integer; overload;
function IfThen(AValue: Boolean; const ATrue: Int64; const AFalse: Int64 = 0): Int64;overload;
function IfThen(AValue: Boolean; const ATrue: Double; const AFalse: Double = 0.0): Double; overload;
function IfThen(AValue: Boolean; const ATrue: stringconst AFalse: string = ''):stringoverload;

Description:

Returns one of two values, depending on the evaluation of an expression.

Example:

var i,j : integer;
		 s:string;
	
i:= 2003; j:= 1973;
s:='abba';
		 
(* fist example *)
IfThen(i > j, i-j, j-1) //results in 2003-1973 = 30

(* second example *)
IfThen(s = ReverseString(s),s + ' equals its reverse order!', 'NO')
//returns 'abba equals its reverse order'