1. Home
  2. Computing & Technology
  3. Delphi Programming
Glossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link Back

Delphi Programming RTL Reference|By Category|Alphabetically|By Unit
 

IfThen

unit
MathStrUtils
category
Miscellaneous routines

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: string; const AFalse: string = ''): string; overload;

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'

in real code
String Types in Delphi
Understanding and managing string data types in Delphi's Object Pascal. Learn about differences between Short, Long, Wide and null-terminated strings.

see also
ReverseString,


 Free Delphi code snippet inside every Delphi Newsletter!
Subscribe to the Newsletter
Name
Email

 Got some code to share? Got a question? Need some help?
Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.