You are previewing Delphi in a Nutshell.
O'Reilly logo
Delphi in a Nutshell

Book Description

With a new name and a new focus on CORBA, database drivers, and Microsoft Back Office applications, Inprise/Borland Delphi is enjoying a resurgence, with a growing user base of programmers who use Delphi for rapid development of enterprise computing applications. Not to rest on success, the latest version of Delphi, Version 5, includes further expansion and refinement of the 3-tier application framework introduced in Delphi 4 and has resulted in a prize-winning product. Delphi in a Nutshell is the first concise reference to Borland/Inprise Delphi available. It succinctly collects all the information you need in one easy-to-use, complete, and accurate volume that goes beyond the product documentation itself. Delphi in a Nutshell starts with the Delphi object model and how to use RTTI (Run Time Type Information) for efficient programming. The rest of the book is the most complete Delphi Pascal language reference available in print, detailing every language element with complete syntax, examples, and methods for use. The book concludes with a look at the compiler, discussing compiler directives in depth.

Table of Contents

  1. Special Upgrade Offer
  2. A Note Regarding Supplemental Files
  3. Preface
    1. Not Your Father’s Pascal
    2. Delphi for Linux
    3. About This Book
    4. Conventions Used in This Book
      1. Note Icons
    5. For More Information
    6. How to Contact Us
    7. Acknowledgments
  4. 1. Delphi Pascal
    1. Units
      1. Forms and Files
      2. Separating Interface from Implementation
      3. Initializing and Finalizing
      4. The System and SysInit Units
    2. Programs
    3. Libraries
      1. Using Dynamic Memory
      2. Sharing Objects
      3. Setting the Image Base
    4. Packages
      1. Design-Time Versus Runtime
      2. Building a Package
    5. Data Types
      1. Integer Types
      2. Real Types
      3. Arrays
        1. Dynamic arrays
        2. Open arrays
        3. Type variant open arrays
      4. Strings
        1. String literals
        2. Mixing string types
        3. Unicode and multibyte strings
      5. Boolean Types
      6. Variants
      7. Pointers
      8. Function and Method Pointers
      9. Type Declarations
    6. Variables and Constants
      1. Typed Constants
      2. Thread Variables
    7. Exception Handling
    8. File I/O
    9. Functions and Procedures
      1. Overloading
      2. Default Parameters
      3. Result Variable
  5. 2. The Delphi Object Model
    1. Classes and Objects
      1. Classes
      2. Objects
      3. Inheritance
      4. Fields
      5. Methods
      6. Constructors
        1. Calling a constructor
        2. Virtual methods and constructors
      7. Destructors
      8. Object Life Cycle
      9. Access Levels
      10. Properties
        1. Array properties
        2. Indexed properties
        3. Default values
        4. Using properties
        5. Class-type properties
    2. Interfaces
      1. Reference counting
        1. Typecasting
        2. Interfaces and object-oriented programming
        3. COM and Corba
    3. Reference Counting
    4. Messages
    5. Memory Management
      1. Memory and DLLs
    6. Old-Style Object Types
  6. 3. Runtime Type Information
    1. Virtual Method Table
    2. Published Declarations
      1. Published Methods
      2. Published Fields and Field Types
      3. Published Properties
    3. The TypInfo Unit
      1. Type Data
      2. Published Properties
    4. Virtual and Dynamic Methods
    5. Initialization and Finalization
    6. Automated Methods
    7. Interfaces
    8. Exploring RTTI
  7. 4. Concurrent Programming
    1. Threads and Processes
      1. Scheduling and States
      2. Synchronizing Threads
        1. Critical sections
        2. Multiple simultaneous readers
      3. Exceptions
      4. Deadlock
      5. Multithreaded Programming
    2. The TThread Class
    3. The BeginThread and EndThread Functions
    4. Thread Local Storage
    5. Processes
    6. Futures
  8. 5. Language Reference
    1. Abs Function
    2. Absolute Directive
    3. Abstract Directive
    4. AbstractErrorProc Variable
    5. AddModuleUnloadProc Procedure
    6. Addr Function
    7. AllocMemCount Variable
    8. AllocMemSize Variable
    9. And Keyword
    10. AnsiChar Type
    11. AnsiString Type
    12. Append Procedure
    13. ArcTan Function
    14. Array Keyword
    15. As Keyword
    16. Asm Keyword
    17. Assembler Directive
    18. Assert Procedure
    19. AssertErrorProc Variable
    20. Assign Procedure
    21. Assigned Function
    22. AssignFile Procedure
    23. At Directive
    24. Automated Directive
    25. Begin Keyword
    26. BeginThread Function
    27. BlockRead Procedure
    28. BlockWrite Procedure
    29. Boolean Type
    30. Break Procedure
    31. Byte Type
    32. ByteBool Type
    33. Cardinal Type
    34. Case Keyword
    35. CDecl Directive
    36. ChangeAnyProc Variable
    37. Char Type
    38. ChDir Procedure
    39. Chr Function
    40. Class Keyword
    41. ClearAnyProc Variable
    42. Close Procedure
    43. CloseFile Procedure
    44. CmdLine Variable
    45. CmdShow Variable
    46. Comp Type
    47. CompToCurrency Function
    48. CompToDouble Function
    49. Concat Function
    50. Const Keyword
    51. Constructor Keyword
    52. Contains Directive
    53. Continue Procedure
    54. Copy Function
    55. Cos Function
    56. Currency Type
    57. CurrencyToComp Procedure
    58. DataMark Variable
    59. DebugHook Variable
    60. Dec Procedure
    61. Default Directive
    62. Default8087CW Variable
    63. Delete Procedure
    64. Destructor Keyword
    65. DispCallByIDProc Variable
    66. Dispid Directive
    67. Dispinterface Keyword
    68. Dispose Procedure
    69. Div Keyword
    70. DllProc Variable
    71. Do Keyword
    72. Double Type
    73. DoubleToComp Procedure
    74. Downto Keyword
    75. Dynamic Directive
    76. Else Keyword
    77. EmptyParam Variable
    78. End Keyword
    79. EnumModules Procedure
    80. EnumResourceModules Procedure
    81. Eof Function
    82. Eoln Function
    83. Erase Procedure
    84. ErrorAddr Variable
    85. ErrorProc Variable
    86. Except Keyword
    87. ExceptClsProc Variable
    88. ExceptionClass Variable
    89. ExceptObjProc Variable
    90. ExceptProc Variable
    91. Exclude Procedure
    92. Exit Procedure
    93. ExitCode Variable
    94. ExitProc Variable
    95. Exp Function
    96. Export Directive
    97. Exports Keyword
    98. Extended Type
    99. External Directive
    100. Far Directive
    101. File Keyword
    102. FileMode Variable
    103. FilePos Function
    104. FileSize Function
    105. FillChar Procedure
    106. Finalization Keyword
    107. Finalize Procedure
    108. Finally Keyword
    109. FindClassHInstance Function
    110. FindHInstance Function
    111. FindResourceHInstance Function
    112. Flush Procedure
    113. For Keyword
    114. Forward Directive
    115. Frac Function
    116. FreeMem Procedure
    117. FreeMemory Function
    118. Function Keyword
    119. GetDir Function
    120. GetHeapStatus Function
    121. GetMem Procedure
    122. GetMemory Function
    123. GetMemoryManager Procedure
    124. GetPackageInfoTable Type
    125. Goto Keyword
    126. Halt Procedure
    127. HeapAllocFlags Variable
    128. Hi Function
    129. High Function
    130. HInstance Variable
    131. HPrevInst Variable
    132. HResult Type
    133. IDispatch Interface
    134. If Keyword
    135. Implementation Keyword
    136. Implements Directive
    137. In Keyword
    138. Inc Procedure
    139. Include Procedure
    140. Index Directive
    141. Inherited Keyword
    142. Initialization Keyword
    143. Initialize Procedure
    144. InitProc Variable
    145. Inline Keyword
    146. Input Variable
    147. Insert Procedure
    148. Int Function
    149. Int64 Type
    150. Integer Type
    151. Interface Keyword
    152. IOResult Function
    153. Is Keyword
    154. IsConsole Variable
    155. IsLibrary Variable
    156. IsMemoryManagerSet Function
    157. IsMultiThread Variable
    158. IUnknown Interface
    159. JITEnable Variable
    160. Label Keyword
    161. Length Function
    162. LibModuleList Variable
    163. Library Keyword
    164. Ln Function
    165. Lo Function
    166. LoadResourceModule Function
    167. LoadResString Function
    168. LongBool Type
    169. LongInt Type
    170. LongWord Type
    171. Low Function
    172. MainInstance Variable
    173. MainThreadID Variable
    174. MaxInt Constant
    175. MaxLongInt Constant
    176. Message Directive
    177. MkDir Procedure
    178. Mod Keyword
    179. ModuleIsCpp Variable
    180. ModuleIsLib Variable
    181. ModuleIsPackage Variable
    182. ModuleUnloadList Variable
    183. Move Procedure
    184. Name Directive
    185. Near Directive
    186. New Procedure
    187. Nil Keyword
    188. Nodefault Directive
    189. NoErrMsg Variable
    190. Not Keyword
    191. Null Variable
    192. Object Keyword
    193. Odd Function
    194. Of Keyword
    195. OleStrToString Function
    196. OleStrToStrVar Procedure
    197. OleVariant Type
    198. On Directive
    199. OpenString Type
    200. Or Keyword
    201. Ord Function
    202. Out Directive
    203. Output Variable
    204. Overload Directive
    205. Override Directive
    206. Package Directive
    207. PackageInfo Type
    208. PackageInfoTable Type
    209. PackageUnitEntry Type
    210. Packed Keyword
    211. PAnsiChar Type
    212. PAnsiString Type
    213. ParamCount Function
    214. ParamStr Function
    215. Pascal Directive
    216. PChar Type
    217. PCurrency Type
    218. PDateTime Type
    219. PExtended Type
    220. PGUID Type
    221. Pi Function
    222. PInt64 Type
    223. PInterfaceEntry Type
    224. PInterfaceTable Type
    225. PLibModule Type
    226. PMemoryManager Type
    227. PModuleUnloadRec Type
    228. Pointer Type
    229. POleVariant Type
    230. Pos Function
    231. Pred Function
    232. PResStringRec Type
    233. Private Directive
    234. Procedure Keyword
    235. Program Keyword
    236. Property Keyword
    237. Protected Directive
    238. PShortString Type
    239. PString Type
    240. Ptr Function
    241. Public Directive
    242. Published Directive
    243. PUnitEntryTable Type
    244. PVarArray Type
    245. PVarData Type
    246. PVariant Type
    247. PVarRec Type
    248. PWideChar Type
    249. PWideString Type
    250. Raise Keyword
    251. RaiseList Function
    252. Random Function
    253. Randomize Procedure
    254. RandSeed Variable
    255. Read Directive
    256. Read Procedure
    257. ReadLn Procedure
    258. Readonly Directive
    259. Real Type
    260. Real48 Type
    261. ReallocMem Procedure
    262. ReallocMemory Function
    263. Record Keyword
    264. RefAnyProc Variable
    265. Register Directive
    266. Register Procedure
    267. RegisterModule Procedure
    268. Reintroduce Directive
    269. RemoveModuleUnloadProc Procedure
    270. Rename Procedure
    271. Repeat Keyword
    272. Requires Directive
    273. Reset Procedure
    274. Resident Directive
    275. Resourcestring Keyword
    276. Result Variable
    277. Rewrite Procedure
    278. RmDir Procedure
    279. Round Function
    280. RunError Procedure
    281. SafeCall Directive
    282. SafeCallErrorProc Variable
    283. Seek Procedure
    284. SeekEof Function
    285. SeekEoln Function
    286. Self Variable
    287. Set Keyword
    288. Set8087CW Procedure
    289. SetInOutRes Procedure
    290. SetLength Procedure
    291. SetMemoryManager Procedure
    292. SetRaiseList Function
    293. SetString Procedure
    294. SetTextBuf Procedure
    295. Shl Keyword
    296. ShortInt Type
    297. ShortString Type
    298. Shr Keyword
    299. Sin Function
    300. Single Type
    301. SizeOf Function
    302. Slice Function
    303. SmallInt Type
    304. Sqr Function
    305. Sqrt Function
    306. StdCall Directive
    307. Stored Directive
    308. Str Procedure
    309. String Keyword
    310. StringOfChar Function
    311. StringToOleStr Function
    312. StringToWideChar Function
    313. Succ Function
    314. Swap Function
    315. SysFreeMem Function
    316. SysGetMem Function
    317. SysReallocMem Function
    318. TClass Type
    319. TDateTime Type
    320. TEnumModuleFuncLW Type
    321. Test8086 Variable
    322. Test8087 Variable
    323. TestFDIV Variable
    324. Text Type
    325. TextFile Type
    326. TGUID Type
    327. THeapStatus Type
    328. Then Keyword
    329. Threadvar Keyword
    330. TInterfacedClass Type
    331. TInterfacedObject Type
    332. TInterfaceEntry Type
    333. TInterfaceTable Type
    334. TLibModule Type
    335. TlsIndex Variable
    336. TlsLast Variable
    337. TMemoryManager Type
    338. TModuleUnloadProcLW Type
    339. TModuleUnloadRec Type
    340. To Keyword
    341. TObject Type
    342. TResStringRec Type
    343. Trunc Function
    344. Truncate Procedure
    345. Try Keyword
    346. TThreadFunc Type
    347. TVarArray Type
    348. TVarArrayBound Type
    349. TVarData Type
    350. TVarRec Type
    351. Type Keyword
    352. TypeInfo Function
    353. Unassigned Variable
    354. UniqueString Procedure
    355. Unit Keyword
    356. UnitEntryTable Type
    357. UnregisterModule Procedure
    358. Until Keyword
    359. UpCase Function
    360. Uses Keyword
    361. Val Procedure
    362. Var Keyword
    363. VarArrayCreate Function
    364. VarArrayDimCount Function
    365. VarArrayHighBound Function
    366. VarArrayLock Function
    367. VarArrayLowBound Function
    368. VarArrayOf Function
    369. VarArrayRedim Procedure
    370. VarArrayRef Function
    371. VarArrayUnlock Procedure
    372. VarAsType Function
    373. VarCast Procedure
    374. VarClear Procedure
    375. VarCopy Procedure
    376. VarDispProc Variable
    377. VarFromDateTime Function
    378. Variant Type
    379. VarIsArray Function
    380. VarIsEmpty Function
    381. VarIsNull Function
    382. VarToDateTime Function
    383. VarToStr Function
    384. VarType Function
    385. Virtual Directive
    386. While Keyword
    387. WideChar Type
    388. WideCharLenToString Function
    389. WideCharLenToStrVar Procedure
    390. WideCharToString Function
    391. WideCharToStrVar Procedure
    392. WideString Type
    393. With Keyword
    394. Word Type
    395. WordBool Type
    396. Write Directive
    397. Write Procedure
    398. WriteLn Procedure
    399. Writeonly Directive
    400. Xor Keyword
  9. 6. System Constants
    1. Variant Type Codes
    2. Open Array Types
    3. Virtual Method Table Offsets
    4. Runtime Error Codes
  10. 7. Operators
    1. Unary Operators
    2. Multiplicative Operators
    3. Additive Operators
    4. Comparison Operators
  11. 8. Compiler Directives
    1. $A Compiler Directive
    2. $Align Compiler Directive
    3. $AppType Compiler Directive
    4. $Assertions Compiler Directive
    5. $B Compiler Directive
    6. $BoolEval Compiler Directive
    7. $C Compiler Directive
    8. $D Compiler Directive
    9. $DebugInfo Compiler Directive
    10. $Define Compiler Directive
    11. $DefinitionInfo Compiler Directive
    12. $DenyPackageUnit Compiler Directive
    13. $Description Compiler Directive
    14. $DesignOnly Compiler Directive
    15. $E Compiler Directive
    16. $Else Compiler Directive
    17. $EndIf Compiler Directive
    18. $ExtendedSyntax Compiler Directive
    19. $ExternalSym Compiler Directive
    20. $G Compiler Directive
    21. $H Compiler Directive
    22. $Hints Compiler Directive
    23. $HppEmit Compiler Directive
    24. $I Compiler Directive
    25. $IfDef Compiler Directive
    26. $IfNDef Compiler Directive
    27. $IfOpt Compiler Directive
    28. $ImageBase Compiler Directive
    29. $ImplicitBuild Compiler Directive
    30. $ImportedData Compiler Directive
    31. $Include Compiler Directive
    32. $IOChecks Compiler Directive
    33. $J Compiler Directive
    34. $L Compiler Directive
    35. $Link Compiler Directive
    36. $LocalSymbols Compiler Directive
    37. $LongStrings Compiler Directive
    38. $M Compiler Directive
    39. $MaxStackSize Compiler Directive
    40. $MinEnumSize Compiler Directive
    41. $MinStackSize Compiler Directive
    42. $NoDefine Compiler Directive
    43. $NoInclude Compiler Directive
    44. $O Compiler Directive
    45. $ObjExportAll Compiler Directive
    46. $OpenStrings Compiler Directive
    47. $Optimization Compiler Directive
    48. $OverflowChecks Compiler Directive
    49. $P Compiler Directive
    50. $Q Compiler Directive
    51. $R Compiler Directive
    52. $RangeChecks Compiler Directive
    53. $RealCompatibility Compiler Directive
    54. $ReferenceInfo Compiler Directive
    55. $Resource Compiler Directive
    56. $RunOnly Compiler Directive
    57. $SafeDivide Compiler Directive
    58. $StackFrames Compiler Directive
    59. $T Compiler Directive
    60. $TypedAddress Compiler Directive
    61. $TypeInfo Compiler Directive
    62. $U
    63. $Undef Compiler Directive
    64. $V Compiler Directive
    65. $VarStringChecks Compiler Directive
    66. $W Compiler Directive
    67. $Warnings Compiler Directive
    68. $WeakPackageUnit Compiler Directive
    69. $WriteableConst Compiler Directive
    70. $X Compiler Directive
    71. $Y Compiler Directive
    72. $Z Compiler Directive
  12. A. Command-Line Tools
    1. Compiler, dcc32.exe
    2. Resource Compiler, brcc32.exe
    3. DFM Converter, convert.exe
    4. Object File Dumper, tdump.exe
    5. IDE, delphi32.exe
  13. B. The SysUtils Unit
    1. Errors and Exceptions
      1. Exception Classes
      2. Error-Handling Support
    2. File Management
      1. File Input and Output
      2. Managing Files
      3. Managing Directories
      4. Managing Disks
      5. Managing Filenames
    3. String Management
      1. ANSI String Functions
      2. PChar Functions
      3. Obsolete String Subroutines
    4. Numeric Conversion
    5. Dates and Times
    6. Localization
    7. Modules
    8. Windows
    9. Miscellaneous
  14. Index
  15. About the Author
  16. Special Upgrade Offer
  17. Copyright