IfThen Function

mla apa chicago
Your Citation
Gajic, Zarko. "IfThen Function." ThoughtCo, Sep. 22, 2016, thoughtco.com/ifthen-function-4091930. Gajic, Zarko. (2016, September 22). IfThen Function. Retrieved from https://www.thoughtco.com/ifthen-function-4091930 Gajic, Zarko. "IfThen Function." ThoughtCo. https://www.thoughtco.com/ifthen-function-4091930 (accessed September 25, 2017).
woman at computer
Hero Images/Getty Images


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;


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


var i,j : integer;
i:= 2003; j:= 1973;
(* 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'