Originale-mail to me for new edition

 

The program heading

 

The program heading specifies the program’s name. It consists of the reserved word program, followed by a valid identifier, followed by a semicolon. The identifier must match the project file name. In the previous example, since the program is called Editor, the project file should be called EDITOR.dpr.

In standard Pascal, a program heading can include parameters after the program name:

program Calc(input, output);

Borland’s Object Pascal compiler ignores these parameters.

 

Topic groups

 

Programs and units: Overview

Program structure and syntax: Overview

The program heading

The program uses clause

The block

Unit structure and syntax: Overview

The unit heading

The interface section

The implementation section

The initialization section

The finalization section

Unit references and the uses clause

The syntax of a uses clause

Multiple and indirect unit references

Circular unit references

 

See also

Program structure and syntax: Overview

The block

The program uses clause

 

 

译文

 

程序首部

 

程序首部由三个要素组成:保留字program、有效标识符、分号。程序首部指定程序名。用于标识程序名的标识符应当与工程文件名相匹配。在前面的例子(程序结构和语法:概述)中,由于程序名叫Editor,所以相应的工程文件的文件名应为EDITOR.dpr(大小写不敏感)。

在标准Pascal中,程序首部还可以在程序名后含有参数,例如:

program Calc(input, output);

BorlandObject Pascal编译器将忽略这些参数。

 

主题组

程序和单元:概述

程序结构和语法:概述

程序首部

程序的uses子句

单元结构和语法:概述

单元首部

接口节

实现节

初始化节

结束节

单元引用和uses子句

uses子句的语法

多重和间接单元应用

循环单元引用

 

相关主题

程序结构和语法:概述

程序的uses子句

 

 

编者注

 

程序名中的参数

尽管Object Pascal对于程序名中含有参数的情况可以编译并且正常运行,但开发者无法获得参数的内容,因为实质上编译器仅仅把这些参数当作一般注释而忽略了。例如,下面的程序首部尽管有效,但在程序的语句中却无法访问参数(编译器将报告错误:Undeclared identifier: ‘A’,即未声明的标识符):

program MyTest(A, B);

...

begin

  ...

if A = 6 then begin

end;

      ...

end.

运行Windows程序可以根据需要传递参数,对于使用Borland开发工具用Object Pascal语言建立的应用程序,要在运行时传递参数,可以用Object Pascal提供的其他途径实现。详细信息可以参阅“Delphi 6 Help -> Visual Component Library Reference”中CmdLineParamStrParamCount等帮助主题。

 

Object Pascal代码编写习惯

Object Pascal编程,开发者可以根据需要在几乎任何位置添加注释,前提是不要将保留字、标识符完整的单词(字)等断开。例如,你可以将程序首部写成:

program      //保留字

Project1  {程序名,对应于文件Project1.dpr}

;          (* 不可缺少的分号 *)