官术网_书友最值得收藏!

Program structure

Each program begins with a heading, which specifies the name of the program, followed by an optional uses clause and a block of declarations and statements. Object Pascal programs are typically divided into modules of source code called units. The optional uses clause contains the list of units that are used by the program. These units, in turn, may use other units specified in their own uses clauses.

Every Object Pascal program uses the built-in System unit. This unit contains predefined constants, types, functions, and procedures, such as basic functions to write and read from the command line or work with files. If you explicitly place the System in the uses clause, you will get an error message that this unit is already used and that it is not legal to use a unit multiple times in one unit. Apart from the System unit, Delphi comes with many units that are not used automatically. They must be included in the uses clause. For example, the System.SysUtils unit is typically used in every Delphi project because it provides some basic functionality, such as the declaration of an exception class needed for structured exception handling. Unit names may contain dots, such as in the case of System.SysUtils. Only the last part is the actual unit name, and all the preceding identifiers constitute a namespace that is used to logically group units. In some cases, it is possible to skip the namespace part, and the compiler will still be able to compile a unit. The order of the units listed in the uses clause is important and determines the order in which they will be initialized.

The first time you compile an app or a package (a special type of project custom components and editors used by the IDE), the compiler produces a compiled unit file (.dcu on Windows) for each unit used in the project. These files are then linked to create an executable file. In the Project menu, or in the Project Manager context menu, there are options to either Compile or Build the current project. When you compile your project, individual units are not recompiled, unless they have been changed since the previous compilation or their compiled units cannot be found. If you choose Build, all the compiled units are regenerated. In fact, the compiler just needs the compiled unit to generate the executable, so it might not have access to the source code of a unit at all. With pre-compiled units, you can build even very big projects very quickly.

主站蜘蛛池模板: 肥西县| 吉木萨尔县| 青岛市| 扶风县| 年辖:市辖区| 余庆县| 九龙县| 东明县| 洪湖市| 修武县| 汾西县| 青龙| 阳东县| 北宁市| 会东县| 林口县| 桂平市| 大名县| 太仓市| 池州市| 泗洪县| 西和县| 绥芬河市| 华宁县| 佛学| 黑河市| 大同县| 太原市| 交口县| 溧水县| 海伦市| 治多县| 个旧市| 江门市| 浦江县| 攀枝花市| 益阳市| 五河县| 阿图什市| 河北省| 彰化县|