Borland’s Delphi is a combination of a modern programming language, an integrated development environment (IDE), and the visual component library (VCL). Delphi’s IDE is readily familiar to anyone who has used similar tools. For example, a WYSIWYG form editor lets you design a window visually, with drag-and-drop ease. More important, the framework is object-oriented, extensible and customizable, due to the power and flexibility of the Delphi programming language.

The heart of Delphi is the Delphi Pascal programming language, which has key features to support the IDE and VCL. It has all the power of a modern object-oriented language, along with the elegance and simplicity of Pascal.

Delphi in a Nutshell is a comprehensive reference manual for Delphi Pascal. It covers the entire language, and it also highlights ways to use the language effectively. Experienced Delphi programmers can use this book as an alphabetical reference. Newcomers to Delphi should spend extra time with the first few chapters. I hope that everyone will find something of value in these pages.

Not Your Father’s Pascal

Delphi Pascal is one of many object-oriented variants of Pascal. Over the years, Delphi has evolved and is no longer recognizable as the Pascal you used in school all those many years ago. In addition to unit-based modular programming and a robust class model, Delphi Pascal has a number of other modern language features, including the following:

  • Interfaces (similar to Java™ and COM interfaces)

  • Unicode strings

  • Properties

  • Exception handling

Delphi started as a Windows programming language and environment, and many Delphi programmers (myself included) consider Delphi to be the best Windows development tool available. Delphi includes full support for COM and ActiveX, an object-oriented widget library (called the Visual Component Library, or VCL), and a rapid-application development environment that is extensible and customizable.

Delphi for Linux

As I write this, Borland is hard at work porting Delphi to Linux. Perhaps when you read this, Delphi for Linux will be available, bringing its integrated development environment to X-Windows, including its WYSIWYG form editor, multi-tier database support, and full CORBA support.

Until Borland finishes this work and releases Delphi for Linux, I can only speculate about how the final product will look. (No, I don’t get any special inside information.) You can rely on the core language being the same in both Delphi for Linux and Delphi for Windows, including classes, objects, interfaces, strings, dynamic arrays, exceptions, and the basic data types. Most of the built-in subroutines will work the same under Linux as under Windows.

Some language features described in this book are clearly Windows specific, such as the CmdShow and DllProc variables or the FindHInstance function. If you want to write code that is portable between Windows and Linux, you must avoid these Windows-specific features.

Delphi for Windows is the best development environment for writing Windows applications and libraries. To attain this premier position, Delphi has incorporated a number of Windows-specific features. Borland has a goal of making Delphi for Linux the best Linux development environment. To achieve that goal, we can expect Delphi to include some Linux-specific features.

I’m just guessing, but I believe it will be feasible to write code that is portable between Windows and Linux. However, you will have to sacrifice some features that are unique to each environment. Writing components that are easily portable, especially interactive controls, will probably be a daunting task. Making an application that is portable will most likely be easier.

About This Book

The first four chapters of this book present information on how to use Delphi effectively, and subsequent chapters form the language reference proper.

Chapter 1, discusses the differences between Delphi Pascal and standard Pascal. If you have used Turbo Pascal or other variants of Object Pascal, you should give Chapter 1 a quick read to learn about the new features that are unique to Delphi Pascal. Similarly, if you haven’t used Pascal since your college days (all those years ago), you must read Chapter 1 to learn about the new and nifty features in Delphi Pascal. You might be surprised at how far the language has come over the years.

Chapter 2, discusses classes and objects in greater depth. If you have used other variants of Object Pascal, you must read this chapter because Delphi’s object model is quite different. If you have experience with other object-oriented programming languages, read Chapter 2 to learn the differences between Delphi and other languages, such as Java and C++.

Chapter 3, covers the key to Delphi’s integrated development environment. RTTI is not documented in Borland’s official help files, but anyone writing or using components (that is, every Delphi programmer) should understand the nature of RTTI, including its limitations and proper uses. Chapter 3 tells you everything there is to know about RTTI, and then some.

Chapter 4, is about using Delphi in a modern, multithreaded, multiprocessor world. Delphi includes several language features to help you write multithreaded applications, but these features can be difficult to use if you do not have much experience with the tricks and traps of multithreaded programming. This chapter gets you started using Delphi effectively to write modern applications.

Chapter 5, is the bulk of the book. The alphabetical reference lists every keyword, directive, subroutine, type, and variable in the Delphi Pascal language and its system units. Full examples show you how to use the language correctly and effectively.

Chapter 6, contains tables of related constants. Chapter 5 is large enough without adding these literals. Moving them to a separate chapter makes the complete reference easier to use.

Chapter 7, describes all the arithmetic and other operators in Delphi Pascal. Symbols do not alphabetize well, so listing the symbol operators in their own chapter makes it easier to find information about a particular operator.

Chapter 8, lists all the special comments that you can include in your source code to control how Delphi compiles and links your program.

Appendix A, describes the usage and options for the various command-line tools that come with Delphi. These tools are not related to the Delphi Pascal language, but they are often overlooked and can be extremely useful for the Delphi professional.

Appendix B, lists all the subroutines, types, and variables in the SysUtils unit. This unit is not built into the compiler (as the System unit is). It is not part of the Delphi Pascal language, but is part of Delphi’s runtime library. Nonetheless, many Delphi professionals have come to rely on SysUtils as though it were part of the language, and indeed, many subroutines in SysUtils are superior to their equivalents in the System unit (such as AnsiPos instead of Pos).

Conventions Used in This Book

The following typographical conventions are used in this book:

Constant width

Used for Delphi identifiers and symbols, including all keywords and directives. In the language reference, constant width shows the syntax elements that must be used exactly as shown. For example, the array declaration requires the square brackets and other symbols, and the type, array, and of keywords to be used as shown:

type Name = array[Index type, ...] of Base type;
Constant width italic

Used in the language reference for syntax elements that must be replaced by your code. In the previous example, you must supply the type Name, the Index type, and the Base type.

Constant Width Bold

Used in longer code examples to highlight the lines that contain the language element being described.


Used to indicate variables, filenames, directory names, URLs, and glossary terms.

Note Icons


The owl icon designates a tip, suggestion, or general note related to the surrounding text.

The turkey icon designates a warning related to the surrounding text.

For More Information

When you have a question about Delphi, you should first consult the Delphi help files. Delphi also comes with numerous examples (in the Demos directory) that are often more helpful than the help files.

If you still cannot find the answer you seek, try posing your question to one of the many Delphi newsgroups. Several standard newsgroups exist, and Borland maintains its own newsgroups on its server, In particular, borland.public.delphi.objectpascal is the appropriate newsgroup for questions related to the Delphi Pascal language.

If you want to know about Delphi’s integrated development environment, about the visual component library, or other topics on Delphi programming, the two most popular books are Mastering Delphi 5, by Marco Cantu (Sybex, 1999) and Delphi 5 Developer’s Guide, by Steve Teixeira and Xavier Pacheco (Sams, 1999).

If you find errors or omissions in this book, please bring them to my attention by sending email to I receive too much email to answer every message individually, but be assured that I read everything (everything that makes it past my anti-spam filters, anyway).

How to Contact Us

The information in this book has been tested and verified, but you may find that features have changed (or you may even find mistakes!). You can send any errors you find, as well as suggestions for future editions, to:

O’Reilly & Associates, Inc.
101 Morris Street
Sebastopol, CA 95472
(800) 998-9938 (in the United States or Canada)
(707) 829-0515 (international or local)
(707) 829-0104 (fax)

There is a web page for this book, where we list any errata, examples, and additional information. You can access this page at:

To ask technical questions or to comment on the book, send email to:

For more information about our books, conferences, software, Resource Centers, and the O’Reilly Network, see our web site at:


I thank Tim O’Reilly for taking a chance with his first Delphi title. I look forward to reading and writing other Delphi books published by O’Reilly.

The technical editors—Allen Bauer and Hallvard Vassbotn—did an excellent job of spotting my mistakes. Hallvard’s copious and detailed comments were invaluable. Any remaining mistakes are ones that I added after the editors finished their thorough work.

I thank my editor, Simon Hayes, and the entire team at O’Reilly—Bob Herbstman, Troy Mott, and the design and production staff—for turning my humble manuscript into this polished book you see now.

None of my books would be possible without the support of family. I thank my wife, Cheryl, and the once-and-future programmer, Arthur, who makes it all worthwhile.

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.