程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi語言學習1-Program和Unit

Delphi語言學習1-Program和Unit

編輯:Delphi

1.單元和程序(Units和Programs)

1)Programs

program Editor;
uses Forms, REAbout, // An "About" box
REMain; // Main form
{$R *.res}
begin
Application.Title := 'Text Editor';
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.

2)Unit

unit Unit1;
interface
uses // List of unit dependencies goes here
implementation
uses // List of unit dependencies goes here
// Implementation of class methods, procedures, and functions goes here
initialization
// Unit initialization code goes here
finalization
// Unit finalization code goes here
end.

2.引用Unit到Unit

uses Forms, Main;
uses
Forms,
Main;
uses Windows, Messages, SysUtils, Strings, Classes, Unit2, MyUnit;

3.引用Unit到program or library

uses 
Windows, Messages, SysUtils,
Strings in 'C:\Classes\Strings.pas', Classes;

4.Unit間接引用

program Prog;
uses Unit2;
const a = b;
//...
unit Unit2;
interface
uses Unit1;
const b = c;
//...
unit Unit1;
interface
const c = 1;
//...

5.Unit的嵌套引用

unit Unit1;
interface
uses Unit2;
// ...
unit Unit2;
interface
uses Unit1;
// ...
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved