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 Lmux, 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...

Data Types

Delphi Pascal supports several extensions to the standard Pascal data types. Like any Pascal language, Delphi supports enumerations, sets, arrays, integer and enumerated subranges, records, and variant records. If you are accustomed to C or C , make sure you understand these standard Pascal types, because they can save you time and headache. The differences include the following Instead of bit masks, sets are usually easier to read. You can use pointers instead of arrays, but arrays are easier...

Libraries

A Delphi library compiles to a standard Windows DLL. A library source file looks the same as a program source file, except that it uses the library keyword instead of program. A library typically has an exports declaration, which lists the routines that the DLL exports. The exports declaration is optional, and if you intend to use a unit in a library, it's usually best to put the exports declaration in the unit, close to the subroutine you are exporting. If you don't use the unit in a library,...

Not Your Fathers 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 Delphi started as a Windows programming language and environment, and many Delphi programmers myself...

Units

Delphi Pascal is a modular programming language, and the basic module is called a unit. To compile and link a Delphi program, you need a program source file and any number of additional units in source or object form. The program source file is usually called a project source file because the project can be a program or a library that is, a dynamically linked library DLL . When Delphi links a program or library, it can statically link all the units into a single .exe or .dll file, or it can...

Functions and Procedures

Delphi supports several extensions to standard Pascal functions and procedures. You can overload routines by declaring multiple routines with the same name, but different numbers or types of parameters. You can declare default values for parameters, thereby making the parameters optional. Almost everything in this section applies equally to functions and procedures, so the term routine is used for both. You can overload a routine name by declaring multiple routines with the same name, but with...

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, Delphi Pascal, 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 leam 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 ,...

Variables and Constants

Unlike standard Pascal, Delphi lets you declare the type of a constant, and you can initialize a global variable to a constant value. Delphi also supports multithreaded applications by letting you declare variables that have distinct values in each thread of your application. When you declare the type of a constant, Delphi sets aside memory for that constant and treats it as a variable. You can assign a new value to the constant, and it keeps that value. In C and C , this entity is called a...

File IO

Traditional Pascal file I O works in Delphi, but you cannot use the standard Input and Output files in a GUI application. To assign a filename to a File or TextFile variable, use AssignFile. Reset and Rewrite work as they do in standard Pascal, or you can use Append to open a file to append to its end. The file must already exist. To close the file, use CloseFile. Table 1-4 lists the I O procedures Delphi provides. Table 1-4 File I O Procedures and Functions Table 1-4 File I O Procedures and...

Exception Handling

Exceptions let you interrupt a program's normal flow of control. You can raise an exception in any function, procedure, or method. The exception causes control to jump to an earlier point in the same routine or in a routine farther back in the call stack. Somewhere in the stack must be a routine that uses a try-except-end statement to catch the exception, or else Delphi calls ExceptProc to handle the exception. Delphi has two related statements for dealing with exceptions. The try-except...