Delphi - Technical Reference Card 7.210
Delphi - Technical Reference Card 7.210
[use FileCtrl]
OpenDialog1.Filter :=
'Text Files (*.txt)|*.txt|All (*.*)|*.*';
OpenDialog1.FilterIndex := 1; List .txt files
OpenDialog1.Execute;
Format Strings:
Format('%.3d', [<integer: 4>]);
'004'
Format('%2.2d%2.2d%4d', [1,1,2000]); '01012000'
Format('%.0n', [<real: 1234567>]);
'1,234,567'
Format('%.2n', [<real: 12345.675>]); '12,345.68'
Format('%m', [<real: 12.34567>]);
'$12.35'
Format('%x', [<integer: 43>]);
'2B'
Format('%p', [<pointer>]);
'8 chr adr'
Format('%s string.', ['Some']);
'Some string.'
Format('{%4.3s} {%4.2s}', ['L123', 'R123']);
'{L12 } { R1}'
Format('%2:s %1:s %0:s', ['1st', '2nd', '3rd']);
'3rd 2nd 1st'
Format('{%*.*f}', [<len: 9>, <dec: 4>, 100*PI]);
'{ 314.1593}'
FloatToStrF(123.45, ffFixed, <len: 4>,<dec: 1>);
'123.5'
FormatMaskText('00000;0;_', '12345');'12345'
FormatFloat('#00,000.0##', 1234.400); '01,234.4'
Date/Time Formats:
FormatDateTime('mm/dd/yyyy', Now); '09/07/2000'
FormatDateTime('hh:n:ss', Now);
'09:5:59'
FormatDateTime('<Specifier>', Now);
<c> 7/29/00 5:24:08 PM;
<m> 7; <mm> 07; <mmm> Jul; <mmmm> July;
<d> 1; <dd> 01; <ddd> Sun; <dddd> Sunday;
<ddddd> 7/9/00; <dddddd> Sunday, July 09, 2000;
<yy> 00; <yyyy> 2000;
<h> 9; <hh> 09; <n> 7; <nn> 07; <s> 9; <ss> 09;
<t> 5:38 PM; <tt> 5:38:28 PM;
<am/pm> pm; <a/p> a; <ampm> PM; </> /; <:> :
String Manipulation:
Chr(<Integer>);
Copy(<SourceString>, <start pos>, <length>);
CompareStr(<SourceString1>, <SourceString2>);
Delete(<SourceString>, <start pos>, <length>);
IntToStr(<SourceInteger>);
Insert(<fromSourceString>, <toSourceString>,
<start pos>);
Length(<SourceString>);
Pos('<find this>', <SourceString>);
SetLength(<SourceString>, <length>);
StringOfChar('<Character>', <quantity>);
StrPas(<PCharString>);
StrPCopy(<SourceString>);
StrToInt(<SourceString>);
StrToIntDef(<SourceString>, <DefaultInteger>);
StrTo<???>(<SourceString>);
<???>ToStr(<Source???>); ??? = Float, Currency,
Date, Time, DateTime
StringReplace(<SourceString>, '<replace this>',
'<with this>', [rfReplaceAll]);
Trim(<SourceString>);
trim l/r blanks
TrimLeft(<SourceString>); trim left blanks
TrimRight(<SourceString>); trim right blanks
LowerCase(<SourceString>);
UpperCase(<SourceString>);
UpCase(<Char>);
Sets:
ThisSet : set of byte;
[0255]
ThisSet := [1, 2, 3, 7]; initialize to 1,2,3,7
ThisSet := ThisSet [3]; exclude number 3
ThisSet := ThisSet + [5]; include number 5
ThisSet := [];
purge all numbers
if 7 in ThisSet ...
Pointer:
Pt : pointer; CharSet := 'AbCd'; Data : string;
Pt := @CharSet;
Data := PChar(Pt^);
Data = 'AbCd'
Data := PChar(Pt^)[0];
Data = 'A'
Math Expressions:
Absolute value:
x := Abs(x);
Addition:
x := y + z;
Address of operator: ptr := @ThisRecord;
Array subscript operator: x := ThisArray[5];
Assignment:
x := 10;
Bitwise AND:
x := x AND $02;
Bitwise NOT:
x := x AND NOT $02;
Bitwise OR:
x := x OR $FF;
Bitwise SHL:
x := x SHL $02;
Bitwise SHR:
x := x SHR $02;
Bitwise XOR:
x := x XOR y;
Decrement:
Dec(x); Dec(x, 2);
Equal to:
if (x = 10) ...
Fraction return:
x := Frac(x);
Greater than or equal to: if (x >= 10) ...
Greater than:
if (x > 10) ...
Hex value operator: x := $FF;
Increment:
Inc(x); Inc(x, 2);
Integer division:
x := y Div 10;
Less than or equal to: if (x <= 10) ...
Less than:
if (x < 10) ...
Logical AND:
if (x = 1) And (y = 2)..
Logical NOT:
if Not Valid then ...
Logical OR:
if (x = 1) Or (y = 2)...
Maximum number return:
x := Max(x, y);
Membership (dot) operator: x := Record.Data;
Minimum number return:
x := Min(x, y);
Multiplication:
x := y * z;
Not equal to:
if (x <> 10) ...
Odd number:
if Odd(9) ...
Ord:
x := Ord('<character>');
Pi:
x := Pi;
Pointer operator:
ThisObject.Data^;
Real division:
x := y / 3.14;
Remainder:
x := y Mod 2;
Round to negative:
x := Floor(x);
Round to positive:
x := Ceil(x);
Square:
x := Sqr(x);
Square root:
x := Sqrt(x);
Subtraction:
x := y z;
Return integer rounded toward zero:
FloatValue := Int(Real);
Discard decimals and return Integer:
Int64Value := Trunc(Real);
Round to the nearest whole number:
Int64Value := Round(Real);
Numeric Variables:
Type
Size Range of Values
Boolean
1 True or False
Byte
1 0 to 255
Cardinal 4 0 to 4,294,967,295
Char
1 0 to 255
Comp
8 9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
Currency 8 922,337,203,685,477.5808 to
922,337,203,685,477.5807
Double
8 5.0 10324 to 1.7 10308
Extended 10 3.4 104932 to 1.1 104932
Int64
8 9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
Integer
4 2,147,483,648 to 2,147,483,647
LongInt
4 2,147,483,648 to 2,147,483,647
LongWord 4 0 to 4,294,967,295
Real
8 5.0 10324 to 1.7 10308
ShortInt 1 128 to 127
Single
4 1.5 1045 to 3.4 1038
SmallInt 2 32,768 to 32,767
WideChar 2 0 to 65,535
Word
2 0 to 65,535
Variant
16 All above
Dec
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
Hex
C0
C1
C2
C3
C4
C5
C6
C7
C8
C9
CA
CB
CC
CD
CE
CF
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
DA
DB
DC
DD
DE
DF
E0
E1
E2
E3
E4
E5
E6
E7
E8
E9
EA
EB
EC
ED
EE
EF
F0
F1
F2
F3
F4
F5
F6
F7
F8
F9
FA
FB
FC
FD
FE
FF
Fn
Binary
1100 0000
1100 0001
1100 0010
1100 0011
1100 0100
1100 0101
1100 0110
1100 0111
1100 1000
1100 1001
1100 1010
1100 1011
1100 1100
1100 1101
1100 1110
1100 1111
1101 0000
1101 0001
1101 0010
1101 0011
1101 0100
1101 0101
1101 0110
1101 0111
1101 1000
1101 1001
1101 1010
1101 1011
1101 1100
1101 1101
1101 1110
1101 1111
1110 0000
1110 0001
1110 0010
1110 0011
1110 0100
1110 0101
1110 0110
1110 0111
1110 1000
1110 1001
1110 1010
1110 1011
1110 1100
1110 1101
1110 1110
1110 1111
1111 0000
1111 0001
1111 0010
1111 0011
1111 0100
1111 0101
1111 0110
1111 0111
1111 1000
1111 1001
1111 1010
1111 1011
1111 1100
1111 1101
1111 1110
1111 1111
v7.20
Bitwise Operations:
[Byte: 1111 0000 Mask Order: 7654 3210]
Byte OR (1 SHL 0);
set bit 1 (1111 0001)
Byte AND (NOT (1 SHL 5)); zero bit 6 (1101 0000)
Byte XOR (1 SHL 7);
toggle bit 8 (0111 0000)
IF Bite AND (1 SHL 4) <> 0 ... test if bit 5 set
[Byte: 1111 0000 Mask Order: 8421 8421]
Byte OR $01;
set bit 1 (1111 0001)
Byte AND (NOT $20);
zero bit 6 (1101 0000)
Byte XOR $80;
toggle bit 8 (0111 0000)
IF Bite AND $10 <> 0 ...
test if bit 5 set
For/While/Case Instructions:
for I := 0 to 9 do begin...
for I := 9 downto 1 do begin...
while I < 100 do begin...
case ANumber of 1 : do this...; 2 : begin...end;
case AString of 'a', 'c'..'z' : do this...;
Messages:
MessageBox(0, '<text>',pchar('<title>'),<mb+mb>)
mbButton: mb_OK mb_OKCancel mb_AbortRetryIgnore
mb_YesNo mb_RetryCancel mb_YesNoCancel
mbBitmap: mb_IconExclamation mb_IconQuestion
mb_IconInformation mb_IconError
mbDefaultButton: mb_DefButton1..mb_DefButton4
mbModality: mb_ApplModal mb_SystemModal
mb_TaskModal
mbSpecial: mb_Default_DeskTop_Only mb_TopMost
mb_Right mb_SetForeground mb_Help
idReturnValues: idOK idCancel idYes idNo
idAbort idIgnore idRetry
MessageDlg('<text>', <mt>, [<mb>, <mb>], 0)
mtBitmap: mtWarning mtError mtInformation
mtConfirmation mtCustom
mbButtonText: mbOK mbCancel mbYes mbNo mbAll
mbAbort mbRetry mbIgnore mbHelp
mrReturnValues: mrNone mrOk mrCancel mrRetry
mrYes mrNo mrIgnore mrAbort mrAll
InputBox('<caption>', '<text>', '<default str>')
ShowMessage('<text>', + #13 + '<text>')
NonStandard Colors:
BlueGreen
= $CCCC00
LtPurple
=
Brick
= $003399
LtPurple
=
Brown
= $006699
LtViolet
=
Brown
= $6058A0
MediumGray =
BurntSienna = $000088
MoneyGreen =
Butterfly
= $EF10B8
Mustard
=
Cosmo
= $C802F2
NavalBlue
=
Cream
= $F0FBFF
OliveGreen =
DkBlue
= $770000
Orange
=
DkGreen
= $005500
PaleBlue
=
DkOrange
= $0099CC
PaleGreen
=
DkPurple
= $AE0D3E
PaleYellow =
DkRose
= $9966FF
PaleYellow =
DkTeal
= $999933
Peach
=
DkViolet
= $993399
Pink
=
Editor
= $950416
Pumpkin
=
Grape
= $B16778
Purple
=
Green
= $2BCA56
RedBaron
=
Honey
= $1CAEE6
Rose
=
Khaki
= $669999
Sea
=
LtBlue
= $FFCC99
SeaGreen
=
LtBrown
= $688FB0
Sky
=
LtCyan
= $FFFF99
SkyBlue
=
LtGrape
= $BD85C7
Slab
=
LtGreen
= $CCFFCC
Violet
=
LtOrange
= $99CCFF
YellowGreen =
$FBA29D
$FFCCCC
$FFCCFF
$A4A0A0
$C0DCC0
$00C4C4
$CC9933
$009966
$33CCFF
$FFFFCC
$79FF91
$CCFFFF
$E2FCFB
$647EF9
$8640FB
$0099FF
$CC0099
$0033FF
$5E24F4
$B90F0B
$CCFF00
$FD8A4D
$F0CAA6
$B3B67E
$FF33FF
$00FFCC
Definitions:
Class: a collection of procedures, functions
and other fields that make up a specific
programming task.
Component: a binary function that performs a
predefined function (edit control,
list box, etc.).
Event Handler: code invoked as a result of an
event.
Events: occur when a user interacts with a
component (OnEnter, OnExit, etc.).
Function: a section of code that performs some
task and returns a value.
Method: a Procedure or Function that is a
member of a class.
Object: a binary portion of a program that
performs a specific programming task.
Object Pascal: Borland modified Pascal language
that extended Pascal, creating a
new language.
Parameter: a value passed to a Procedure
or Function.
Pointer: a variable that holds the address of
another variable.
Procedure: a section of code that performs some
task but does not returns a value.
Properties: control how a component operates
(color, width, etc.).
Unit: a text file of Delphi code that is
compiled into machine code.
Uses List: a list of external units referenced
by a Unit.
Compiler Directives:
{$DEFINE $name} set to True
{$UNDEF $name} set to False
{$IF $name} ... {$ELSE} ... {$ENDIF}
{$DEFINE anyname}
{$IFDEF anyname} ... {$ENDIF}
Standard
{$DEFINE
{$DEFINE
{$DEFINE
{$DEFINE
{$DEFINE
Conditional Symbols:
Debug}
{$IFDEF Debug}
WIN32}
{$IFDEF WIN32}
VER120}
{$IFDEF VER120}
CPU386}
{$IFDEF CPU386}
CONSOLE} {$IFDEF CONSOLE}
(default OFF)
{$ALIGN}
{$APPTYPE}
{$ASSERTIONS}
{$BOOLEVAL}
{$DEBUGINFO}
{$DEFINITIINFO}
{$DESCRIPTION '..'}
{$E extension}
{$EXTENDEDSYNTAX}
{$HINTS}
{$IMAGEBASE number}
{$INCLUDE filename}
{$IOCHECKS}
{$LINK filename}
{$LOCALSYMBOLS}
{$LONGSTRINGS}
User:
{$MAXSTACKSIZE num}
{$MINENUMSIZE 1}
{$MINSTACKSIZE num}
{$OPENSTRINGS}
{$OPTIMIZATION}
{$OVERFLOWCHECKS}
{$R filename.RES}
{$RANGECHECKS}
{$REALCOMPATIBILITY}
{$SAFEDIVIDE}
{$STACKFRAMES}
{$TYPEDADDRESS}
{$TYPEINFO}
{$VARSTRINGCHECKS}
{$WARNINGS}
{$WEAKPACKAGEUNIT}
{$WRITEABLECONST}