Ⅰ 誰給我來點計算機的參考文獻啊
正則表達式基礎知識
一個正則表達式就是由普通字元(例如字元 a 到 z)以及特殊字元(稱為元字元)組成的文字模式。該模式描述在查找文字主體時待匹配的一個或多個字元串。正則表達式作為一個模板,將某個字元模式與所搜索的字元串進行匹配。如:
JScript VBScript 匹配
/^\[ \t]*$/ "^\[ \t]*$" 匹配一個空白行。
/\d{2}-\d{5}/ "\d{2}-\d{5}" 驗證一個ID 號碼是否由一個2位數字,一個連字元以及一個5位數字組成。
/<(.*)>.*<\/\1>/ "<(.*)>.*<\/\1>" 匹配一個 HTML 標記。
下表是元字元及其在正則表達式上下文中的行為的一個完整列表:
字元 描述
\ 將下一個字元標記為一個特殊字元、或一個原義字元、或一個 向後引用、或一個八進制轉義符。例如,'n' 匹配字元 "n"。'\n' 匹配一個換行符。序列 '\\' 匹配 "\" 而 "\(" 則匹配 "("。
^ 匹配輸入字元串的開始位置。如果設置了 RegExp 對象的 Multiline 屬性,^ 也匹配 '\n' 或 '\r' 之後的位置。
$ 匹配輸入字元串的結束位置。如果設置了RegExp 對象的 Multiline 屬性,$ 也匹配 '\n' 或 '\r' 之前的位置。
* 匹配前面的子表達式零次或多次。例如,zo* 能匹配 "z" 以及 "zoo"。* 等價於{0,}。
+ 匹配前面的子表達式一次或多次。例如,'zo+' 能匹配 "zo" 以及 "zoo",但不能匹配 "z"。+ 等價於 {1,}。
? 匹配前面的子表達式零次或一次。例如,"do(es)?" 可以匹配 "do" 或 "does" 中的"do" 。? 等價於 {0,1}。
{n} n 是一個非負整數。匹配確定的 n 次。例如,'o{2}' 不能匹配 "Bob" 中的 'o',但是能匹配 "food" 中的兩個 o。
{n,} n 是一個非負整數。至少匹配n 次。例如,'o{2,}' 不能匹配 "Bob" 中的 'o',但能匹配 "foooood" 中的所有 o。'o{1,}' 等價於 'o+'。'o{0,}' 則等價於 'o*'。
{n,m} m 和 n 均為非負整數,其中n <= m。最少匹配 n 次且最多匹配 m 次。例如,"o{1,3}" 將匹配 "fooooood" 中的前三個 o。'o{0,1}' 等價於 'o?'。請注意在逗號和兩個數之間不能有空格。
? 當該字元緊跟在任何一個其他限制符 (*, +, ?, {n}, {n,}, {n,m}) 後面時,匹配模式是非貪婪的。非貪婪模式盡可能少的匹配所搜索的字元串,而默認的貪婪模式則盡可能多的匹配所搜索的字元串。例如,對於字元串 "oooo",'o+?' 將匹配單個 "o",而 'o+' 將匹配所有 'o'。
. 匹配除 "\n" 之外的任何單個字元。要匹配包括 '\n' 在內的任何字元,請使用象 '[.\n]' 的模式。
(pattern) 匹配 pattern 並獲取這一匹配。所獲取的匹配可以從產生的 Matches 集合得到,在VBScript 中使用 SubMatches 集合,在JScript 中則使用 $0…$9 屬性。要匹配圓括弧字元,請使用 '\(' 或 '\)'。
(?:pattern) 匹配 pattern 但不獲取匹配結果,也就是說這是一個非獲取匹配,不進行存儲供以後使用。這在使用 "或" 字元 (|) 來組合一個模式的各個部分是很有用。例如, 'instr(?:y|ies) 就是一個比 'instry|instries' 更簡略的表達式。
(?=pattern) 正向預查,在任何匹配 pattern 的字元串開始處匹配查找字元串。這是一個非獲取匹配,也就是說,該匹配不需要獲取供以後使用。例如,'Windows (?=95|98|NT|2000)' 能匹配 "Windows 2000" 中的 "Windows" ,但不能匹配 "Windows 3.1" 中的 "Windows"。預查不消耗字元,也就是說,在一個匹配發生後,在最後一次匹配之後立即開始下一次匹配的搜索,而不是從包含預查的字元之後開始。
(?!pattern) 負向預查,在任何不匹配 pattern 的字元串開始處匹配查找字元串。這是一個非獲取匹配,也就是說,該匹配不需要獲取供以後使用。例如'Windows (?!95|98|NT|2000)' 能匹配 "Windows 3.1" 中的 "Windows",但不能匹配 "Windows 2000" 中的 "Windows"。預查不消耗字元,也就是說,在一個匹配發生後,在最後一次匹配之後立即開始下一次匹配的搜索,而不是從包含預查的字元之後開始
x|y 匹配 x 或 y。例如,'z|food' 能匹配 "z" 或 "food"。'(z|f)ood' 則匹配 "zood" 或 "food"。
[xyz] 字元集合。匹配所包含的任意一個字元。例如, '[abc]' 可以匹配 "plain" 中的 'a'。
[^xyz] 負值字元集合。匹配未包含的任意字元。例如, '[^abc]' 可以匹配 "plain" 中的'p'。
[a-z] 字元范圍。匹配指定范圍內的任意字元。例如,'[a-z]' 可以匹配 'a' 到 'z' 范圍內的任意小寫字母字元。
[^a-z] 負值字元范圍。匹配任何不在指定范圍內的任意字元。例如,'[^a-z]' 可以匹配任何不在 'a' 到 'z' 范圍內的任意字元。
\b 匹配一個單詞邊界,也就是指單詞和空格間的位置。例如, 'er\b' 可以匹配"never" 中的 'er',但不能匹配 "verb" 中的 'er'。
\B 匹配非單詞邊界。'er\B' 能匹配 "verb" 中的 'er',但不能匹配 "never" 中的 'er'。
\cx 匹配由 x 指明的控制字元。例如, \cM 匹配一個 Control-M 或回車符。x 的值必須為 A-Z 或 a-z 之一。否則,將 c 視為一個原義的 'c' 字元。
\d 匹配一個數字字元。等價於 [0-9]。
\D 匹配一個非數字字元。等價於 [^0-9]。
\f 匹配一個換頁符。等價於 \x0c 和 \cL。
\n 匹配一個換行符。等價於 \x0a 和 \cJ。
\r 匹配一個回車符。等價於 \x0d 和 \cM。
\s 匹配任何空白字元,包括空格、製表符、換頁符等等。等價於 [ \f\n\r\t\v]。
\S 匹配任何非空白字元。等價於 [^ \f\n\r\t\v]。
\t 匹配一個製表符。等價於 \x09 和 \cI。
\v 匹配一個垂直製表符。等價於 \x0b 和 \cK。
\w 匹配包括下劃線的任何單詞字元。等價於'[A-Za-z0-9_]'。
\W 匹配任何非單詞字元。等價於 '[^A-Za-z0-9_]'。
\xn 匹配 n,其中 n 為十六進制轉義值。十六進制轉義值必須為確定的兩個數字長。例如,'\x41' 匹配 "A"。'\x041' 則等價於 '\x04' & "1"。正則表達式中可以使用 ASCII 編碼。.
\num 匹配 num,其中 num 是一個正整數。對所獲取的匹配的引用。例如,'(.)\1' 匹配兩個連續的相同字元。
\n 標識一個八進制轉義值或一個向後引用。如果 \n 之前至少 n 個獲取的子表達式,則 n 為向後引用。否則,如果 n 為八進制數字 (0-7),則 n 為一個八進制轉義值。
\nm 標識一個八進制轉義值或一個向後引用。如果 \nm 之前至少有 nm 個獲得子表達式,則 nm 為向後引用。如果 \nm 之前至少有 n 個獲取,則 n 為一個後跟文字 m 的向後引用。如果前面的條件都不滿足,若 n 和 m 均為八進制數字 (0-7),則 \nm 將匹配八進制轉義值 nm。
\nml 如果 n 為八進制數字 (0-3),且 m 和 l 均為八進制數字 (0-7),則匹配八進制轉義值 nml。
\un 匹配 n,其中 n 是一個用四個十六進制數字表示的 Unicode 字元。例如, \u00A9 匹配版權符號 (&;)。
下面看幾個例子:
"^The":表示所有以"The"開始的字元串("There","The cat"等);
"of despair$":表示所以以"of despair"結尾的字元串;
"^abc$":表示開始和結尾都是"abc"的字元串——呵呵,只有"abc"自己了;
"notice":表示任何包含"notice"的字元串。
'*','+'和'?'這三個符號,表示一個或一序列字元重復出現的次數。它們分別表示「沒有或
更多」,「一次或更多」還有「沒有或一次」。下面是幾個例子:
"ab*":表示一個字元串有一個a後面跟著零個或若干個b。("a", "ab", "abbb",……);
"ab+":表示一個字元串有一個a後面跟著至少一個b或者更多;
"ab?":表示一個字元串有一個a後面跟著零個或者一個b;
"a?b+$":表示在字元串的末尾有零個或一個a跟著一個或幾個b。
也可以使用范圍,用大括弧括起,用以表示重復次數的范圍。
"ab{2}":表示一個字元串有一個a跟著2個b("abb");
"ab{2,}":表示一個字元串有一個a跟著至少2個b;
"ab{3,5}":表示一個字元串有一個a跟著3到5個b。
請注意,你必須指定范圍的下限(如:"{0,2}"而不是"{,2}")。還有,你可能注意到了,'*','+'和
'?'相當於"{0,}","{1,}"和"{0,1}"。
還有一個'¦',表示「或」操作:
"hi¦hello":表示一個字元串里有"hi"或者"hello";
"(b¦cd)ef":表示"bef"或"cdef";
"(a¦b)*c":表示一串"a""b"混合的字元串後面跟一個"c";
'.'可以替代任何字元:
"a.[0-9]":表示一個字元串有一個"a"後面跟著一個任意字元和一個數字;
"^.{3}$":表示有任意三個字元的字元串(長度為3個字元);
方括弧表示某些字元允許在一個字元串中的某一特定位置出現:
"[ab]":表示一個字元串有一個"a"或"b"(相當於"a¦b");
"[a-d]":表示一個字元串包含小寫的'a'到'd'中的一個(相當於"a¦b¦c¦d"或者"[abcd]");
"^[a-zA-Z]":表示一個以字母開頭的字元串;
"[0-9]%":表示一個百分號前有一位的數字;
",[a-zA-Z0-9]$":表示一個字元串以一個逗號後面跟著一個字母或數字結束。
你也可以在方括弧里用'^'表示不希望出現的字元,'^'應在方括弧里的第一位。(如:"%[^a-zA-Z]%"表
示兩個百分號中不應該出現字母)。
為了逐字表達,必須在"^.$()¦*+?{\"這些字元前加上轉移字元'\'。
請注意在方括弧中,不需要轉義字元。
五種常見的 PHP 設計模式
設計模式只是為 Java™ 架構師准備的 —— 至少您可能一直這樣認為。實際上,設計模式對於每個人都非常有用。如果這些工具不是 「架構太空人」 的專利,那麼它們又是什麼?為什麼說它們在 PHP 應用程序中非常有用?本文解釋了這些問題。
設計模式 一書將設計模式引入軟體社區,該書的作者是 Erich Gamma、Richard Helm、Ralph Johnson 和 John Vlissides Design(俗稱 「四人幫」)。所介紹的設計模式背後的核心概念非常簡單。經過多年的軟體開發實踐,Gamma 等人發現了某些具有固定設計的模式,就像建築師設計房子和建築物一樣,可以為浴室的位置或廚房的構造方式開發模板。使用這些模板或者說設計模式 意味著可以更快地設計更好的建築物。同樣的概念也適用於軟體。
設計模式不僅代表著更快開發健壯軟體的有用方法,而且還提供了以友好的術語封裝大型理念的方法。例如,您可以說您正在編寫一個提供鬆散耦合的消息傳遞系統,也可以說你正在編寫名稱為觀察者 的模式。
用較小的示例展示模式的價值是非常困難的。這往往有些大材小用的意味,因為模式實際上是在大型代碼庫中發揮作用的。本文不展示大型應用程序,所以您 需要思索的是在您自己的大型應用程序中應用示例原理的方法 —— 而不是本文演示的代碼本身。這不是說您不應該在小應用程序中使用模式。很多良好的應用程序都以小應用程序為起點,逐漸發展到大型應用程序,所以沒有理由不 以此類扎實的編碼實踐為基礎。
既然您已經了解了設計模式以及它們的有用之處,現在我們來看看 PHP V5 的五種常用模式。
工廠模式
最初在設計模式 一書中,許多設計模式都鼓勵使用鬆散耦合。要理解這個概念,讓我們最好談一下許多開發人員從事大型系統的艱苦歷程。在更改一個代碼片段時,就會發生問題,系統其他部分 —— 您曾認為完全不相關的部分中也有可能出現級聯破壞。
該問題在於緊密耦合 。系統某個部分中的函數和類嚴重依賴於系統的其他部分中函數和類的行為和結構。您需要一組模式,使這些類能夠相互通信,但不希望將它們緊密綁定在一起,以避免出現聯鎖。
在大型系統中,許多代碼依賴於少數幾個關鍵類。需要更改這些類時,可能會出現困難。例如,假設您有一個從文件讀取的 User 類。您希望將其更改為從資料庫讀取的其他類,但是,所有的代碼都引用從文件讀取的原始類。這時候,使用工廠模式會很方便。
工廠模式 是一種類,它具有為您創建對象的某些方法。您可以使用工廠類創建對象,而不直接使用 new。這樣,如果您想要更改所創建的對象類型,只需更改該工廠即可。使用該工廠的所有代碼會自動更改。
清單 1 顯示工廠類的一個示列。等式的伺服器端包括兩個部分:資料庫和一組 PHP 頁面,這些頁面允許您添加反饋、請求反饋列表並獲取與特定反饋相關的文章。
清單 1. Factory1.php
<?php
interface IUser
{
function getName();
}
class User implements IUser
{
public function __construct( $id ) { }
public function getName()
{
return "Jack";
}
}
class UserFactory
{
public static function Create( $id )
{
return new User( $id );
}
}
$uo = UserFactory::Create( 1 );
echo( $uo->getName()."\n" );
?>
IUser 介面定義用戶對象應執行什麼操作。IUser 的實現稱為 User,UserFactory 工廠類則創建 IUser 對象。此關系可以用圖 1 中的 UML 表示。
圖 1. 工廠類及其相關 IUser 介面和用戶類
如果您使用 php 解釋器在命令行上運行此代碼,將得到如下結果:
% php factory1.php
Jack
%
測試代碼會向工廠請求 User 對象,並輸出 getName 方法的結果。
有一種工廠模式的變體使用工廠方法。類中的這些公共靜態方法構造該類型的對象。如果創建此類型的對象非常重要,此方法非常有用。例如,假設您需要先 創建對象,然後設置許多屬性。此版本的工廠模式會將該進程封裝在單個位置中,這樣,不用復制復雜的初始化代碼,也不必將復制好的代碼在在代碼庫中到處粘 貼。
清單 2 顯示使用工廠方法的一個示例。
清單 2. Factory2.php
<?php
interface IUser
{
function getName();
}
class User implements IUser
{
public static function Load( $id )
{
return new User( $id );
}
public static function Create( )
{
return new User( null );
}
public function __construct( $id ) { }
public function getName()
{
return "Jack";
}
}
$uo = User::Load( 1 );
echo( $uo->getName()."\n" );
?>
這段代碼要簡單得多。它僅有一個介面 IUser 和一個實現此介面的 User 類。User 類有兩個創建對象的靜態方法。此關系可用圖 2 中的 UML 表示。
圖 2. IUser 介面和帶有工廠方法的 user 類
在命令行中運行腳本產生的結果與清單 1 的結果相同,如下所示:
% php factory2.php
Jack
%
如上所述,有時此類模式在規模較小的環境中似乎有些大材小用。不過,最好還是學習這種扎實的編碼形式,以便應用於任意規模的項目中。
單元素模式
某些應用程序資源是獨占的,因為有且只有一個此類型的資源。例如,通過資料庫句柄到資料庫的連接是獨占的。您希望在應用程序中共享資料庫句柄,因為在保持連接打開或關閉時,它是一種開銷,在獲取單個頁面的過程中更是如此。
單元素模式可以滿足此要求。如果應用程序每次包含且僅包含一個對象,那麼這個對象就是一個單元素(Singleton)。清單 3 中的代碼顯示了 PHP V5 中的一個資料庫連接單元素。
清單 3. Singleton.php
<?php
require_once("DB.php");
class DatabaseConnection
{
public static function get()
{
static $db = null;
if ( $db == null )
$db = new DatabaseConnection();
return $db;
}
private $_handle = null;
private function __construct()
{
$dsn = 'mysql://root:password@localhost/photos';
$this->_handle =& DB::Connect( $dsn, array() );
}
public function handle()
{
return $this->_handle;
}
}
print( "Handle = ".DatabaseConnection::get()->handle()."\n" );
print( "Handle = ".DatabaseConnection::get()->handle()."\n" );
?>
此代碼顯示名為 DatabaseConnection 的單個類。您不能創建自已的 DatabaseConnection,因為構造函數是專用的。但使用靜態 get 方法,您可以獲得且僅獲得一個 DatabaseConnection 對象。此代碼的 UML 如圖 3 所示。
圖 3. 資料庫連接單元素
在兩次調用間,handle 方法返回的資料庫句柄是相同的,這就是最好的證明。您可以在命令行中運行代碼來觀察這一點。
% php singleton.php
Handle = Object id #3
Handle = Object id #3
%
返回的兩個句柄是同一對象。如果您在整個應用程序中使用資料庫連接單元素,那麼就可以在任何地方重用同一句柄。
您可以使用全局變數存儲資料庫句柄,但是,該方法僅適用於較小的應用程序。在較大的應用程序中,應避免使用全局變數,並使用對象和方法訪問資源。
觀察者模式
觀察者模式為您提供了避免組件之間緊密耦合的另一種方法。該模式非常簡單:一個對象通過添加一個方法(該方法允許另一個對象,即觀察者 注冊自己)使本身變得可觀察。當可觀察的對象更改時,它會將消息發送到已注冊的觀察者。這些觀察者使用該信息執行的操作與可觀察的對象無關。結果是對象可以相互對話,而不必了解原因。
一個簡單示例是系統中的用戶列表。清單 4 中的代碼顯示一個用戶列表,添加用戶時,它將發送出一條消息。添加用戶時,通過發送消息的日誌觀察者可以觀察此列表。
清單 4. Observer.php
<?php
interface IObserver
{
function onChanged( $sender, $args );
}
interface IObservable
{
function addObserver( $observer );
}
class UserList implements IObservable
{
private $_observers = array();
public function addCustomer( $name )
{
foreach( $this->_observers as $obs )
$obs->onChanged( $this, $name );
}
public function addObserver( $observer )
{
$this->_observers []= $observer;
}
}
class UserListLogger implements IObserver
{
public function onChanged( $sender, $args )
{
echo( "'$args' added to user list\n" );
}
}
$ul = new UserList();
$ul->addObserver( new UserListLogger() );
$ul->addCustomer( "Jack" );
?>
此代碼定義四個元素:兩個介面和兩個類。IObservable 介面定義可以被觀察的對象,UserList 實現該介面,以便將本身注冊為可觀察。IObserver 列表定義要通過怎樣的方法才能成為觀察者,UserListLogger 實現 IObserver 介面。圖 4 的 UML 中展示了這些元素。
圖 4. 可觀察的用戶列表和用戶列表事件日誌程序
如果在命令行中運行它,您將看到以下輸出:
% php observer.php
'Jack' added to user list
%
測試代碼創建 UserList,並將 UserListLogger 觀察者添加到其中。然後添加一個消費者,並將這一更改通知 UserListLogger。
認識到 UserList 不知道日誌程序將執行什麼操作很關鍵。可能存在一個或多個執行其他操作的偵聽程序。例如,您可能有一個向新用戶發送消息的觀察者,歡迎新用戶使用該系統。這種方法的價值在於 UserList 忽略所有依賴它的對象,它主要關注在列表更改時維護用戶列表並發送消息這一工作。
此模式不限於內存中的對象。它是在較大的應用程序中使用的資料庫驅動的消息查詢系統的基礎。
命令鏈模式
命令鏈 模式以鬆散耦合主題為基礎,發送消息、命令和請求,或通過一組處理程序發送任意內容。每個處理程序都會自行判斷自己能否處理請求。如果可以,該請求被處理,進程停止。您可以為系統添加或移除處理程序,而不影響其他處理程序。清單 5 顯示了此模式的一個示例。
清單 5. Chain.php
<?php
interface ICommand
{
function onCommand( $name, $args );
}
class CommandChain
{
private $_commands = array();
public function addCommand( $cmd )
{
$this->_commands []= $cmd;
}
public function runCommand( $name, $args )
{
foreach( $this->_commands as $cmd )
{
if ( $cmd->onCommand( $name, $args ) )
return;
}
}
}
class UserCommand implements ICommand
{
public function onCommand( $name, $args )
{
if ( $name != 'addUser' ) return false;
echo( "UserCommand handling 'addUser'\n" );
return true;
}
}
class MailCommand implements ICommand
{
public function onCommand( $name, $args )
{
if ( $name != 'mail' ) return false;
echo( "MailCommand handling 'mail'\n" );
return true;
}
}
$cc = new CommandChain();
$cc->addCommand( new UserCommand() );
$cc->addCommand( new MailCommand() );
$cc->runCommand( 'addUser', null );
$cc->runCommand( 'mail', null );
?>
此代碼定義維護 ICommand 對象列表的 CommandChain 類。兩個類都可以實現 ICommand 介面 —— 一個對郵件的請求作出響應,另一個對添加用戶作出響應。 圖 5 給出了 UML。
圖 5. 命令鏈及其相關命令
如果您運行包含某些測試代碼的腳本,則會得到以下輸出:
% php chain.php
UserCommand handling 'addUser'
MailCommand handling 'mail'
%
代碼首先創建 CommandChain 對象,並為它添加兩個命令對象的實例。然後運行兩個命令以查看誰對這些命令作出了響應。如果命令的名稱匹配 UserCommand 或 MailCommand,則代碼失敗,不發生任何操作。
為處理請求而創建可擴展的架構時,命令鏈模式很有價值,使用它可以解決許多問題。
策略模式
我們講述的最後一個設計模式是策略 模式。在此模式中,演算法是從復雜類提取的,因而可以方便地替換。例如,如果要更改搜索引擎中排列頁的方法,則策略模式是一個不錯的選擇。思考一下搜索引擎 的幾個部分 —— 一部分遍歷頁面,一部分對每頁排列,另一部分基於排列的結果排序。在復雜的示例中,這些部分都在同一個類中。通過使用策略模式,您可將排列部分放入另一個 類中,以便更改頁排列的方式,而不影響搜索引擎的其餘代碼。
作為一個較簡單的示例,清單 6 顯示了一個用戶列表類,它提供了一個根據一組即插即用的策略查找一組用戶的方法。
清單 6. Strategy.php
<?php
interface IStrategy
{
function filter( $record );
}
class FindAfterStrategy implements IStrategy
{
private $_name;
public function __construct( $name )
{
$this->_name = $name;
}
public function filter( $record )
{
return strcmp( $this->_name, $record ) <= 0;
}
}
class RandomStrategy implements IStrategy
{
public function filter( $record )
{
return rand( 0, 1 ) >= 0.5;
}
}
class UserList
{
private $_list = array();
public function __construct( $names )
{
if ( $names != null )
{
foreach( $names as $name )
{
$this->_list []= $name;
}
}
}
public function add( $name )
{
$this->_list []= $name;
}
public function find( $filter )
{
$recs = array();
foreach( $this->_list as $user )
{
if ( $filter->filter( $user ) )
$recs []= $user;
}
return $recs;
}
}
$ul = new UserList( array( "Andy", "Jack", "Lori", "Megan" ) );
$f1 = $ul->find( new FindAfterStrategy( "J" ) );
print_r( $f1 );
$f2 = $ul->find( new RandomStrategy() );
print_r( $f2 );
?>
此代碼的 UML 如圖 6 所示。
圖 6. 用戶列表和用於選擇用戶的策略
UserList 類是打包名稱數組的一個包裝器。它實現 find 方法,該方法利用幾個策略之一來選擇這些名稱的子集。這些策略由 IStrategy 介面定義,該介面有兩個實現:一個隨機選擇用戶,另一個根據指定名稱選擇其後的所有名稱。運行測試代碼時,將得到以下輸出:
% php strategy.php
Array
(
[0] => Jack
[1] => Lori
[2] => Megan
)
Array
(
[0] => Andy
[1] => Megan
)
%
測試代碼為兩個策略運行同一用戶列表,並顯示結果。在第一種情況中,策略查找排列在 J 後的任何名稱,所以您將得到 Jack、Lori 和 Megan。第二個策略隨機選取名稱,每次會產生不同的結果。在這種情況下,結果為 Andy 和 Megan。
策略模式非常適合復雜數據管理系統或數據處理系統,二者在數據篩選、搜索或處理的方式方面需要較高的靈活性。
結束語
本文介紹的僅僅是 PHP 應用程序中使用的幾種最常見的設計模式。在設計模式 一書中演示了更多的設計模式。不要因架構的神秘性而放棄。模式是一種絕妙的理念,適用於任何編程語言、任何技能水平。
Ⅱ Delphi的命令行編譯命令
Borland出品的Delphi,有著閃電般的編譯速度,但是在界面控制項使用較多、工程項目較大的時候,編譯一個工程仍需要一段時間,打開龐大的Delphi IDE,也需要時間。其實,在一個工程開發結束,調試完成之後的Release編譯,完全可以用命令行來執行,因為Delphi的編譯器參數不像C++編譯器那樣復雜。
筆者把Delphi聯機手冊中關於命令行編譯(command-line compiler)的幾篇主題作了翻譯,希望對Delphi開發人員有幫助。
目錄
1. Command-line compiler
命令行編譯器
2. Command-line compiler options
命令行編譯器選項
3. Compiler directive options
編譯器指令選項
4. Compiler mode options
編譯模式選項
5. DCC32.CFG file
編譯器配置文件DCC32.CFG
6. Debug options
調試選項
7. Directory options
目錄選項
8. IDE command-line options
IDE命令行選項
9. Generated files
幾個IDE自動生成的文件介紹
Command-line compiler
命令行編譯器
Delphi's command-line compiler (dcc32.EXE) lets you invoke all the functions of the IDE compiler (DELPHI32.EXE) from the DOS command line (see IDE command-line options. Run the command-line compiler from the DOS prompt using the syntax:
Delphi』s命令行編譯器(dcc32.exe)允許你從DOS命令行方式(參照:IDE命令行選項)實現IDE編譯器(delphi32.exe)的所有功能。用DOS命令運行命令行編譯器語法如下:
dcc32 [options] filename [options]
dcc32 [選項] [文件名] [選項]
where options are zero or more parameters that provide information to the compiler and filename is the name of the source file to compile. If you type dcc32 alone, it displays a help screen of command-line options and syntax.
零或多個參數給編譯器提供信息,文件名指定需要編譯的源文件名。如果你單獨輸入dcc32,它會顯示一個關於命令行編譯的選項和語法的屏幕。
If filename does not have an extension, the command-line compiler assumes .dpr, then .pas, if no .dpr is found. If the file you're compiling to doesn't have an extension, you must append a period (.) to the end of the filename.
如果文件名沒有擴展名,命令行編譯器會查找擴展名為.dpr的同名文件,如果找不到,則查找擴展名為.pas的同名文件。如果你的源文件確實沒有擴展名,你需要在文件名的末尾添加(.)。
If the source text contained in filename is a program, the compiler creates an executable file named filename.EXE. If filename contains a library, the compiler creates a file named filename.DLL. If filename contains a package, the compiler creates a file named filename.BPL. If filename contains a unit, the compiler creates a unit file named filename.dcu.
如果指定的源文件是一個工程文件,編譯器會創建一個擴展名為.EXE的同名可執行文件。如果指定的源文件是一個庫文件,編譯器創建一個擴展名為.DLL的同名動態鏈接庫文件。如果指定的源文件是一個包文件,編譯器會創建一個擴展名為.BPL的同名包。如果指定的源文件是一個單元文件,編譯器會創建一個擴展名為.dcu的目標代碼文件。
You can specify a number of options for the command-line compiler. An option consists of a slash (/) or immediately followed by an option letter. In some cases, the option letter is followed by additional information, such as a number, a symbol, or a directory name. Options can be given in any order and can come before or after the file name.
你可以為命令行編譯器指定多個參數。一個參數包含一個破折號「-」(或「/」)和緊跟著的一個選項字元構成。通常情況下,選項字元後面會跟一些附加的信息,如一個數字、一個符號、一個目錄等。選項可以是任意順序並且可以在源文件名前面或後面。
Command-line compiler options
命令行編譯選項
The IDE lets you set various options through the menus; the command-line compiler gives you access to these options using the slash (/) delimiter. You can also precede options with a hyphen (-) instead of a slash (/), but those options that start with a hyphen must be separated by blanks. For example, the following two command lines are equivalent and legal:
IDE允許你使用菜單來設置各種編譯選項,而命令行編譯器允許你使用字元「/」作為分隔符來設定這些編譯選項。你也可以使用連字元「-」來代替「/」,但是用「-」引出的參數之間必須用空格隔開。例如,下面兩個命令都是等同的也是合法的:
DCC -IC:\DELPHI -DDEBUG SORTNAME -$R- -$U+
DCC /IC:\DELPHI/DDEBUG SORTNAME /$R-/$U+
The first command line uses hyphens with at least one blank separating options. The second uses slashes and no separation is needed.
第一個編譯命令用「-」引出參數,且參數之間有多個空格分隔。第二個編譯命令用「/」引出參數,參數之間不必要分隔。
The following table lists the command-line options. In addition to the listed options, all single-letter compiler directives can be specified on the command line, as described in Compiler directive options.
下列表中列出所有的命令行參數。在附加的選項列表中,所有的單字元編譯器指令都可以在命令行編譯中使用,詳情請參照:編譯器指令。
Option Description
選項 描述
Aunit=alias 設置單元別名
B 編譯所有單元
CC 編譯控制台程序
CG 編譯圖形界面程序
Ddefines 編譯條件符號定義
Epath 可執行文件輸出路徑
Foffset 查找運行期間錯誤
GD 生成完整.Map文件
GP 生成.Map文件Public段
GS 生成.Map文件Segment段
H 輸出提示信息
Ipaths 文件包含路徑
J 生成.Obj目標文件
JP 生成C++類型.Obj目標文件
Kaddress Set image base address
LEpath 包.BPL文件輸出路徑
LNpath .dcp文件輸出路徑
LUpackage 使用運行期間包列表
M 編譯有改動的源文件
Npath dcu/dpu文件輸出目錄
Opaths .Obj文件(匯編目標代碼文件)路徑
P 按8.3格式文件名查找
Q 安靜模式
Rpaths 資源文件(.RES)路徑
TXext 目標文件擴展名
Upaths 單元文件路徑
V 為Turbo Debugger生成調試信息文件
VN 以.Giant格式生成包含命名空間的調試信息文件(將用於C++Builder)
VR 生成調試信息文件.rsm
W 輸出警告信息
Z Disable implicit compilation
$directive Compiler directives
--Help 顯示編譯選項的幫助。同樣的,如果你在命令行單獨輸入dcc32,也會顯示編譯選項的幫助。
--version 顯示產品名稱和版本
Compiler directive options
編譯器指令選項
Delphi supports the compiler directives described in Compiler directives. The $ and D command-line options allow you to change the default states of most compiler directives. Using $ and D on the command line is equivalent to inserting the corresponding compiler directive at the beginning of each source file compiled.
Delphi支持用編譯器指令關鍵字描述的編譯器指令。使用「$」和「D」命令行選項可以改變所有的默認編譯器狀態。用「$」和「D」命令行選項等同於在源文件的前面添加編譯器指令。
Switch directive option
編譯器指令選項開關
The $ option lets you change the default state of all of the switch directives. The syntax of a switch directive option is $ followed by the directive letter, followed by a plus (+) or a minus (-). For example:
「$」允許你改變每一種編譯器指令默認狀態。編譯器指令的語法是「$」後緊跟一個指令字元,再跟一個「-」或「+」。例如:
dcc32 MYSTUFF -$R-
compiles MYSTUFF.pas with range-checking turned off, while:
不使用邊界檢查編譯MYSTUFF.pas單元:
dcc32 MYSTUFF -$R+
compiles it with range checking turned on. Note that if a {$R+} or {$R-} compiler directive appears in the source text, it overrides the -$R command-line option.
使用界面檢查編譯MYSTUFF.pas單元。如果將編譯器指令{$R+}或{$R-}添加到源文件的開始,它將覆蓋從命令行傳入的參數。
You can repeat the -$ option in order to specify multiple compiler directives:
你可以用多個「$」來指定多個編譯器指令,如:
dcc32 MYSTUFF -$R--$I--$V--$U+
Alternately, the command-line compiler lets you write a list of directives (except for $M), separated by commas:
命令行編譯器允許作用逗號分隔的編譯器指定列表,如:
dcc32 MYSTUFF -$R-,I-,V-,U+
只需要用一個「$」符號。
Only one dollar sign ($) is needed.
注意,因為$M的格式不一樣,你不能在逗號分隔的指令列表中使用$M
Note that, because of its format, you cannot use the $M directive in a list of directives separated by commas.
Conditional defines option
條件編譯選項
The -D option lets you define conditional symbols, corresponding to the {$DEFINE symbol} compiler directive. The -D option must be followed by one or more conditional symbols separated by semicolons (;). For example, the following command line:
「-D」選項允許你定義一個編譯條件,符合你用{$DEFINE symbol}定義的編譯器指令。「-D」選項後必須跟隨一或多個用分號分隔的編譯條件符號,如下命令:
dcc32 MYSTUFF -DIOCHECK;DEBUG;LIST
defines three conditional symbols, iocheck, debug, and list, for the compilation of MYSTUFF.pas. This is equivalent to inserting:
定義了三個編譯條件符號:IOCHECK,DEBUG,LIST,用於MYSTUFF.pas單元中。這等同於在源文件中插入以下語句:
{$DEFINE IOCHECK}
{$DEFINE DEBUG}
{$DEFINE LIST}
at the beginning of MYSTUFF.pas. If you specify multiple -D directives, you can concatenate the symbol lists. Therefore:
如果你指定了多個「-D」選項,你可以聯接它們,如下:
dcc32 MYSTUFF -DIOCHECK-DDEBUG-DLIST
is equivalent to the first example.
等同於第一個例子。
Compiler mode options
編譯模式選項
A few options affect how the compiler itself functions. As with the other options, you can use these with either the hyphen or the slash format. Remember to separate the options with at least one blank.
有幾個選項能影響編譯器自身的功能。像其它選項一個,你可以使用「/」或「-」的格式。別忘了用至少一個空格分隔這些選項。
Make (-M) option
選項(-M)
The command-line compiler has built-in MAKE logic to aid in project maintenance. The -M option instructs command-line compiler to check all units upon which the file being compiled depends. Using this option results in a much quicker compile time.
命令行編譯器使用構造邏輯的方式來維護工程。「-M」選項指示編譯器檢查所有與編譯文件相關聯的文件。用這個參數會導致編譯時間增大。
A unit is recompiled under the following conditions:
一個源文件在下列情況下會重新編譯:
The source file for that unit has been modified since the unit file was created.
源文件被創建以來被修改過;
用「$I」指令包含的任何文件,用「$L」包含的任何.Obj文件,或用「$R」關聯的任何資源文件.Res,比源文件中的要新;
Any file included with the $I directive, any .OBJ file linked in by the $L directive, or any .res file referenced by the $R directive, is newer than the unit file.
The interface section of a unit referenced in a uses statement has changed.
單元介面部分interface的uses段有改動。
Units compiled with the -Z option are excluded from the make logic.
在單元編譯時指令「-Z」在構造邏輯期不被接受。
If you were applying this option to the previous example, the command would be:
如果你在上一個例子中使用這個指令,編譯命令就應該是:
dcc32 MYSTUFF -M
Build all (-B) option
編譯所有 選項(-B)
Instead of relying on the -M option to determine what needs to be updated, you can tell command-line compiler to update all units upon which your program depends using the -B option. You can't use -M and -B at the same time. The -B option is slower than the -M option and is usually unnecessary.
用於取代要知道哪些單元需要更新-M的選項,你可以使用-B選項來更新所有你的程序中關聯的單元。你不能在程序中同時使用-M和-B。選項-B比-M速度更慢,而且它並不是必需的。
If you were using this option in the previous example, the command would be
如果你在前一個例子中使用這個參數,編譯命令就應該是:
dcc32 MYSTUFF -B
Find error (-F) option
查找錯誤 選項(-F)
When a program terminates e to a runtime error, it displays an error code and the address at which the error occurred. By specifying that address in a -Faddress option, you can locate the statement in the source text that caused the error, provided your program and units were compiled with debug information enabled (via the $D compiler directive).
當一個程序由於運行期間錯誤而終止時,它會顯示一個錯誤號和錯誤地址在錯誤發生時。用-Faddress選項來指定錯誤地址,你在源文件中能找到引發錯誤的位置,如果你的程序和單元編譯時附加了調試信息(使用$D編譯器指令)。
In order for the command-line compiler to find the runtime error with -F, you must compile the program with all the same command-line parameters you used the first time you compiled it.
為了命令行編譯器能用-F選項查找運行期間錯誤,你必須傳遞與第一次編譯時相同的指令列表。
As mentioned previously, you must compile your program and units with debug information enabled for the command-line compiler to be able to find runtime errors. By default, all programs and units are compiled with debug information enabled, but if you turn it off, using a {$D-} compiler directive or a -$D- option, the command-line compiler will not be able to locate runtime errors.
先前提到過,你的程序和單元必須啟用調試信息,命令行編譯器才能查找運行期間錯誤。默認情況下,所有的程序和單都是啟用調試信息的,除非你用{-D}或-$D-指令關閉它,這樣,命令行編譯器就不能查找運行期間錯誤了。
Use packages (-LU) option
使用包(-LU)選項
Use the -LU option to list additional runtime packages that you want to use in the application being compiled. Runtime packages already listed in the Project Options dialog box need not be repeated on the command line.
使用-LU選項來在編譯時添加你應用程序中要用到的運行期間包。運行期間包已經在「工程選項」對話框中列舉的,不必再在命令行中添加。
Disable implicit compilation (-Z) option
(此選項在delphi6.0/7.0中有不同描述,在此不作翻譯)
The -Z option prevents packages and units from being implicitly recompiled later. With packages, it is equivalent to placing {$ IMPLICITBUILD OFF} in the .dpk file. Use -Z when compiling packages that provide low-level functionality, that change infrequently between builds, or whose source code will not be distributed.
Target file extension (-TX) option
目標文件擴展名(-TX)選項
The -TX option lets you override the default extension for the output file. For example,
選項-TX允許你改寫默認的輸出文件擴展名。例如:
dcc32 MYSTUFF -TXSYS
generates compiled output in a file called MYSTUFF.SYS.
生成的將是一個叫做MYSTUFF.SYS的文件。
Quiet (-Q) option
安靜模式(-Q)選項
The quiet mode option suppresses the printing of file names and line numbers ring compilation. When the command-line compiler is invoked with the quiet mode option
安靜模式選項禁止在編譯時顯示文件名及代碼行數,如果命令行編譯器調用這個選項的話。
dcc32 MYSTUFF -Q its output is limited to the startup right message and the usual statistics at the end of compilation. If any errors occur, they will be reported.
它的輸出僅限於起始時行版權信息以及結尾的統計信息。當然,如果發生錯誤,它也會輸出。
DCC32.CFG file
DCC32.CFG配置文件
You can set up a list of options in a configuration file called DCC32.CFG, which will then be used in addition to the options entered on the command line. Each line in configuration file corresponds to an extra command-line argument inserted before the actual command-line arguments. Thus, by creating a configuration file, you can change the default setting of any command-line option.
你可以設置一個編譯選項列表到一個叫做DCC32.CFG的配置文件中,它將用於編譯時附加到命令行參數後。配置文件的每一行都相當於一個額外的命令行參數插入到實際的命令行參數前(注意,是實際參數前)。因而,你可以使用這個配置文件改變一些命令行參數的默認設置。
The command-line compiler lets you enter the same command-line option several times, ignoring all but the last occurrence. This way, even though you've changed some settings with a configuration file, you can still override them on the command line.
命令行編譯器允許你輸入相同的命令行參數,它將忽略所有除最後一個之外。這個的話,盡管通過配置文件你可以改變一些設置,你仍然可以覆蓋它使用命令行參數。
When dcc32 starts, it looks for DCC32.CFG in the current directory. If the file isn't found there, dcc32 looks in the directory where DCC32.EXE resides.
當dcc32啟動時,它查找DCC32.CFG文件在當前目錄。如果文件沒有找到,dcc32會查找它所在的目錄。
Here's an example DCC32.CFG file, defining some default directories for include, object, and unit files, and changing the default states of the $O and $R compiler directives:
以下是一個DCC32.CFG配置文件的例子,定義了關於文件包含、OBJ文件包含、單元文件搜索路徑信息,並改變了編譯器指令$O和$R的默認值。
-IC:\DELPHI\INC;C:\DELPHI\SRC
-OC:\DELPHI\ASM
-UC:\DELPHI\UNITS
-$R+
-$O-
Now, if you type:
現在,如果你輸入:
dcc32 MYSTUFF
the compiler performs as if you had typed the following:
編譯器把它當作你輸入如下命令:
dcc32 -IC:\DELPHI\INC;C:\DELPHI\SRC -OC:\DELPHI\ASM -UC:\DELPHI\UNITS -$R+ -$O- MYSTUFF
Debug options
調試選項
The compiler has two sets of command-line options that enable you to generate external debugging information: the map file options and the debug info options.
編譯器有兩個命令行參數可以生成外部調試信息:MAP文件選項和調試信息選項。
Map file (-G) options
Map文件(-G)選項
The -G option instructs the command-line compiler to generate a .map file that shows the layout of the executable file. Unlike the binary format of executable and .dcu files, a .map file is a legible text file that can be output on a printer or loaded into the editor. The -G option must be followed by the letter S, P, or D to indicate the desired level of information in the .map file. A .MAP file is divided into three sections:
選項-G指示命令行編譯器生成一個.map文件來查看一個可執行文件的布局。不同於可二進制的可執行文件和.dcu文件,.map文件是一個可讀的文本文件,可以被列印或是其它文本編輯器編輯。選項-G後必須跟字元S、P或D,去決定你想要在.map文件列出的信息。一個.MAP文件被分成三個節:
Segment
Publics
Line Numbers
-GS outputs only the Segment section, -GP outputs the Segment and Publics section, and -GD outputs all three sections. -GD also generates a .DRC file that contains tables of all string constants declared using the resourcestring keyword.
-GS選項只輸出Segment Section,-GS選項輸出Segment和Publics,-GD輸出所有的三個Sections.-GD選項也生成一個擴展名為.DRC的文件包含所有的用resourcestring關鍵字聲明的字元串常量。
For moles (program and units) compiled in the {$D+,L+} state (the default), the Publics section shows all global variables, proceres, and functions, and the Line Numbers section shows line numbers for all proceres and functions in the mole. In the {$D+,L-} state, only symbols defined in a unit's interface part are listed in the Publics section. For moles compiled in the {$D-} state, there are no entries in the Line Numbers section.
用默認的編譯選項{$D+,L+}編譯模塊(程序或單元),Publics Section列舉所有的全局變數、過程和函數,Line Numbers Section列舉模塊中所有的過程和函數的行號。如果用{$D+,L-}編譯選項編譯模塊,Publics Section中僅列舉在單元的interface部分定義的符號。如果用{$D-}選項編譯模塊,在Line Numbers Section沒有任何入口。
Debug info (-V) options
調度選項(-V)
The -V options (-V, -VN. and -VR), which cause the compiler to generate debug information, can be combined on the command line.
選項-V、-VN、-VR會指示編譯器生成調試信息,它們能在命令行中組合使用。
Generate Turbo Debugger debug info (-V) option
生成Turbo Debugger使用的調試信息的選項(-V)
When you specify the -V option on the command line, the compiler appends Turbo Debugger 5.0-compatible external debug information at the end of the executable file. Turbo Debugger includes both source- and machine-level debugging and powerful breakpoints.
當你在命令行中使用-V選項時,編譯器會在可執行文件的末尾附加與Turbo Debugger5.0一致的外部調試信息。Turbo Debugger包含代碼和硬體級別的強大的斷點。
Even though the debug information generated by -V makes the resulting executable file larger, it does not affect the actual code in the executable, and does not require additional memory to run the program.
雖然附加調試信息到查執行文件中會使可執行文件增大,但是它並不影響實際可執行文件中的可執行代碼,也不需要額外的內存來啟動程序。
The extent of debug information appended to the executable file depends on the setting of the $D and $L compiler directives in each of the moles (program and units) that make up the application. For moles compiled in the {$D+,L+} state, which is the default, all constant, variable, type, procere, and function symbols are known to the debugger. In the {$D+,L-} state, only symbols defined in a unit's interface section are known to the debugger. In the {$D-} state, no line-number records are generated, so the debugger cannot display source lines whe
Ⅲ 怎樣在Delphi里插入版權符號08-CSDN論壇
d2009之前不支持unicode,可以用第三方基於unicode的組件來實現,d2009及以後就直接支持了。
Ⅳ DELPHI怎麼用
DELPHI 這樣用。
Over!
Ⅳ 如何在命令行上編譯我的delphi項目
Borland出品的Delphi,有著閃電般的編譯速度,但是在界面控制項使用較多、工程項目較大的時候,編譯一個工程仍需要一段時間,打開龐大的Delphi IDE,也需要時間。其實,在一個工程開發結束,調試完成之後的Release編譯,完全可以用命令行來執行,因為Delphi的編譯器參數不像C++編譯器那樣復雜。
筆者把Delphi聯機手冊中關於命令行編譯(command-line compiler)的幾篇主題作了翻譯,希望對Delphi開發人員有幫助。
目錄
1. Command-line compiler
命令行編譯器
2. Command-line compiler options
命令行編譯器選項
3. Compiler directive options
編譯器指令選項
4. Compiler mode options
編譯模式選項
5. DCC32.CFG file
編譯器配置文件DCC32.CFG
6. Debug options
調試選項
7. Directory options
目錄選項
8. IDE command-line options
IDE命令行選項
9. Generated files
幾個IDE自動生成的文件介紹
Command-line compiler
命令行編譯器
Delphi's command-line compiler (dcc32.EXE) lets you invoke all the functions of the IDE compiler (DELPHI32.EXE) from the DOS command line (see IDE command-line options. Run the command-line compiler from the DOS prompt using the syntax:
Delphi』s命令行編譯器(dcc32.exe)允許你從DOS命令行方式(參照:IDE命令行選項)實現IDE編譯器(delphi32.exe)的所有功能。用DOS命令運行命令行編譯器語法如下:
dcc32 [options] filename [options]
dcc32 [選項] [文件名] [選項]
where options are zero or more parameters that provide information to the compiler and filename is the name of the source file to compile. If you type dcc32 alone, it displays a help screen of command-line options and syntax.
零或多個參數給編譯器提供信息,文件名指定需要編譯的源文件名。如果你單獨輸入dcc32,它會顯示一個關於命令行編譯的選項和語法的屏幕。
If filename does not have an extension, the command-line compiler assumes .dpr, then .pas, if no .dpr is found. If the file you're compiling to doesn't have an extension, you must append a period (.) to the end of the filename.
如果文件名沒有擴展名,命令行編譯器會查找擴展名為.dpr的同名文件,如果找不到,則查找擴展名為.pas的同名文件。如果你的源文件確實沒有擴展名,你需要在文件名的末尾添加(.)。
If the source text contained in filename is a program, the compiler creates an executable file named filename.EXE. If filename contains a library, the compiler creates a file named filename.DLL. If filename contains a package, the compiler creates a file named filename.BPL. If filename contains a unit, the compiler creates a unit file named filename.dcu.
如果指定的源文件是一個工程文件,編譯器會創建一個擴展名為.EXE的同名可執行文件。如果指定的源文件是一個庫文件,編譯器創建一個擴展名為.DLL的同名動態鏈接庫文件。如果指定的源文件是一個包文件,編譯器會創建一個擴展名為.BPL的同名包。如果指定的源文件是一個單元文件,編譯器會創建一個擴展名為.dcu的目標代碼文件。
You can specify a number of options for the command-line compiler. An option consists of a slash (/) or immediately followed by an option letter. In some cases, the option letter is followed by additional information, such as a number, a symbol, or a directory name. Options can be given in any order and can come before or after the file name.
你可以為命令行編譯器指定多個參數。一個參數包含一個破折號「-」(或「/」)和緊跟著的一個選項字元構成。通常情況下,選項字元後面會跟一些附加的信息,如一個數字、一個符號、一個目錄等。選項可以是任意順序並且可以在源文件名前面或後面。
Command-line compiler options
命令行編譯選項
The IDE lets you set various options through the menus; the command-line compiler gives you access to these options using the slash (/) delimiter. You can also precede options with a hyphen (-) instead of a slash (/), but those options that start with a hyphen must be separated by blanks. For example, the following two command lines are equivalent and legal:
IDE允許你使用菜單來設置各種編譯選項,而命令行編譯器允許你使用字元「/」作為分隔符來設定這些編譯選項。你也可以使用連字元「-」來代替「/」,但是用「-」引出的參數之間必須用空格隔開。例如,下面兩個命令都是等同的也是合法的:
DCC -IC:/DELPHI -DDEBUG SORTNAME -$R- -$U+
DCC /IC:/DELPHI/DDEBUG SORTNAME /$R-/$U+
The first command line uses hyphens with at least one blank separating options. The second uses slashes and no separation is needed.
第一個編譯命令用「-」引出參數,且參數之間有多個空格分隔。第二個編譯命令用「/」引出參數,參數之間不必要分隔。
The following table lists the command-line options. In addition to the listed options, all single-letter compiler directives can be specified on the command line, as described in Compiler directive options.
下列表中列出所有的命令行參數。在附加的選項列表中,所有的單字元編譯器指令都可以在命令行編譯中使用,詳情請參照:編譯器指令。
Option Description
選項 描述
Aunit=alias 設置單元別名
B 編譯所有單元
CC 編譯控制台程序
CG 編譯圖形界面程序
Ddefines 編譯條件符號定義
Epath 可執行文件輸出路徑
Foffset 查找運行期間錯誤
GD 生成完整.Map文件
GP 生成.Map文件Public段
GS 生成.Map文件Segment段
H 輸出提示信息
Ipaths 文件包含路徑
J 生成.Obj目標文件
JP 生成C++類型.Obj目標文件
Kaddress Set image base address
LEpath 包.BPL文件輸出路徑
LNpath .dcp文件輸出路徑
LUpackage 使用運行期間包列表
M 編譯有改動的源文件
Npath dcu/dpu文件輸出目錄
Opaths .Obj文件(匯編目標代碼文件)路徑
P 按8.3格式文件名查找
Q 安靜模式
Rpaths 資源文件(.RES)路徑
TXext 目標文件擴展名
Upaths 單元文件路徑
V 為Turbo Debugger生成調試信息文件
VN 以.Giant格式生成包含命名空間的調試信息文件(將用於C++Builder)
VR 生成調試信息文件.rsm
W 輸出警告信息
Z Disable implicit compilation
$directive Compiler directives
--Help 顯示編譯選項的幫助。同樣的,如果你在命令行單獨輸入dcc32,也會顯示編譯選項的幫助。
--version 顯示產品名稱和版本
Compiler directive options
編譯器指令選項
Delphi supports the compiler directives described in Compiler directives. The $ and D command-line options allow you to change the default states of most compiler directives. Using $ and D on the command line is equivalent to inserting the corresponding compiler directive at the beginning of each source file compiled.
Delphi支持用編譯器指令關鍵字描述的編譯器指令。使用「$」和「D」命令行選項可以改變所有的默認編譯器狀態。用「$」和「D」命令行選項等同於在源文件的前面添加編譯器指令。
Switch directive option
編譯器指令選項開關
The $ option lets you change the default state of all of the switch directives. The syntax of a switch directive option is $ followed by the directive letter, followed by a plus (+) or a minus (-). For example:
「$」允許你改變每一種編譯器指令默認狀態。編譯器指令的語法是「$」後緊跟一個指令字元,再跟一個「-」或「+」。例如:
dcc32 MYSTUFF -$R-
compiles MYSTUFF.pas with range-checking turned off, while:
不使用邊界檢查編譯MYSTUFF.pas單元:
dcc32 MYSTUFF -$R+
compiles it with range checking turned on. Note that if a {$R+} or {$R-} compiler directive appears in the source text, it overrides the -$R command-line option.
使用界面檢查編譯MYSTUFF.pas單元。如果將編譯器指令{$R+}或{$R-}添加到源文件的開始,它將覆蓋從命令行傳入的參數。
You can repeat the -$ option in order to specify multiple compiler directives:
你可以用多個「$」來指定多個編譯器指令,如:
dcc32 MYSTUFF -$R--$I--$V--$U+
Alternately, the command-line compiler lets you write a list of directives (except for $M), separated by commas:
命令行編譯器允許作用逗號分隔的編譯器指定列表,如:
dcc32 MYSTUFF -$R-,I-,V-,U+
只需要用一個「$」符號。
Only one dollar sign ($) is needed.
注意,因為$M的格式不一樣,你不能在逗號分隔的指令列表中使用$M
Note that, because of its format, you cannot use the $M directive in a list of directives separated by commas.
Conditional defines option
條件編譯選項
The -D option lets you define conditional symbols, corresponding to the {$DEFINE symbol} compiler directive. The -D option must be followed by one or more conditional symbols separated by semicolons (;). For example, the following command line:
「-D」選項允許你定義一個編譯條件,符合你用{$DEFINE symbol}定義的編譯器指令。「-D」選項後必須跟隨一或多個用分號分隔的編譯條件符號,如下命令:
dcc32 MYSTUFF -DIOCHECK;DEBUG;LIST
defines three conditional symbols, iocheck, debug, and list, for the compilation of MYSTUFF.pas. This is equivalent to inserting:
定義了三個編譯條件符號:IOCHECK,DEBUG,LIST,用於MYSTUFF.pas單元中。這等同於在源文件中插入以下語句:
{$DEFINE IOCHECK}
{$DEFINE DEBUG}
{$DEFINE LIST}
如果你指定了多個「-D」選項,你可以聯接它們,如下:
dcc32 MYSTUFF -DIOCHECK-DDEBUG-DLIST
等同於第一個例子。
編譯模式選項
有幾個選項能影響編譯器自身的功能。像其它選項一個,你可以使用「/」或「-」的格式。別忘了用至少一個空格分隔這些選項。
選項(-M)
命令行編譯器使用構造邏輯的方式來維護工程。「-M」選項指示編譯器檢查所有與編譯文件相關聯的文件。用這個參數會導致編譯時間增大。
一個源文件在下列情況下會重新編譯:
The source file for that unit has been modified since the unit file was created.
源文件被創建以來被修改過;
用「$I」指令包含的任何文件,用「$L」包含的任何.Obj文件,或用「$R」關聯的任何資源文件.Res,比源文件中的要新;
單元介面部分interface的uses段有改動。
在單元編譯時指令「-Z」在構造邏輯期不被接受。
If you were applying this option to the previous example, the command would be:
如果你在上一個例子中使用這個指令,編譯命令就應該是:
dcc32 MYSTUFF -M
編譯所有 選項(-B)
用於取代要知道哪些單元需要更新-M的選項,你可以使用-B選項來更新所有你的程序中關聯的單元。你不能在程序中同時使用-M和-B。選項-B比-M速度更慢,而且它並不是必需的。
如果你在前一個例子中使用這個參數,編譯命令就應該是:
dcc32 MYSTUFF -B
查找錯誤 選項(-F)
當一個程序由於運行期間錯誤而終止時,它會顯示一個錯誤號和錯誤地址在錯誤發生時。用-Faddress選項來指定錯誤地址,你在源文件中能找到引發錯誤的位置,如果你的程序和單元編譯時附加了調試信息(使用$D編譯器指令)。
為了命令行編譯器能用-F選項查找運行期間錯誤,你必須傳遞與第一次編譯時相同的指令列表。
先前提到過,你的程序和單元必須啟用調試信息,命令行編譯器才能查找運行期間錯誤。默認情況下,所有的程序和單都是啟用調試信息的,除非你用{-D}或-$D-指令關閉它,這樣,命令行編譯器就不能查找運行期間錯誤了。
使用包(-LU)選項
使用-LU選項來在編譯時添加你應用程序中要用到的運行期間包。運行期間包已經在「工程選項」對話框中列舉的,不必再在命令行中添加。
Disable implicit compilation (-Z) option
(此選項在delphi6.0/7.0中有不同描述,在此不作翻譯)
目標文件擴展名(-TX)選項
選項-TX允許你改寫默認的輸出文件擴展名。例如:
dcc32 MYSTUFF -TXSYS
生成的將是一個叫做MYSTUFF.SYS的文件。
Quiet (-Q) option
安靜模式(-Q)選項
安靜模式選項禁止在編譯時顯示文件名及代碼行數,如果命令行編譯器調用這個選項的話。
它的輸出僅限於起始時行版權信息以及結尾的統計信息。當然,如果發生錯誤,它也會輸出。
DCC32.CFG file
DCC32.CFG配置文件
你可以設置一個編譯選項列表到一個叫做DCC32.CFG的配置文件中,它將用於編譯時附加到命令行參數後。配置文件的每一行都相當於一個額外的命令行參數插入到實際的命令行參數前(注意,是實際參數前)。因而,你可以使用這個配置文件改變一些命令行參數的默認設置。
命令行編譯器允許你輸入相同的命令行參數,它將忽略所有除最後一個之外。這個的話,盡管通過配置文件你可以改變一些設置,你仍然可以覆蓋它使用命令行參數。
當dcc32啟動時,它查找DCC32.CFG文件在當前目錄。如果文件沒有找到,dcc32會查找它所在的目錄。
以下是一個DCC32.CFG配置文件的例子,定義了關於文件包含、OBJ文件包含、單元文件搜索路徑信息,並改變了編譯器指令$O和$R的默認值。
-IC:/DELPHI/INC;C:/DELPHI/SRC
-OC:/DELPHI/ASM
-UC:/DELPHI/UNITS
-$R+
-$O-
現在,如果你輸入:
dcc32 MYSTUFF
編譯器把它當作你輸入如下命令:
dcc32 -IC:/DELPHI/INC;C:/DELPHI/SRC -OC:/DELPHI/ASM -UC:/DELPHI/UNITS -$R+ -$O- MYSTUFF
調試選項
編譯器有兩個命令行參數可以生成外部調試信息:MAP文件選項和調試信息選項。
Map file (-G) options
Map文件(-G)選項
選項-G指示命令行編譯器生成一個.map文件來查看一個可執行文件的布局。不同於可二進制的可執行文件和.dcu文件,.map文件是一個可讀的文本文件,可以被列印或是其它文本編輯器編輯。選項-G後必須跟字元S、P或D,去決定你想要在.map文件列出的信息。一個.MAP文件被分成三個節:
Segment
Publics
Line Numbers
-GS選項只輸出Segment Section,-GS選項輸出Segment和Publics,-GD輸出所有的三個Sections.-GD選項也生成一個擴展名為.DRC的文件包含所有的用resourcestring關鍵字聲明的字元串常量。
用默認的編譯選項{$D+,L+}編譯模塊(程序或單元),Publics Section列舉所有的全局變數、過程和函數,Line Numbers Section列舉模塊中所有的過程和函數的行號。如果用{$D+,L-}編譯選項編譯模塊,Publics Section中僅列舉在單元的interface部分定義的符號。如果用{$D-}選項編譯模塊,在Line Numbers Section沒有任何入口。
調度選項(-V)
選項-V、-VN、-VR會指示編譯器生成調試信息,它們能在命令行中組合使用。
生成Turbo Debugger使用的調試信息的選項(-V)
當你在命令行中使用-V選項時,編譯器會在可執行文件的末尾附加與Turbo Debugger5.0一致的外部調試信息。Turbo Debugger包含代碼和硬體級別的強大的斷點。
雖然附加調試信息到查執行文件中會使可執行文件增大,但是它並不影響實際可執行文件中的可執行代碼,也不需要額外的內存來啟動程序。
Ⅵ 怎樣在Delphi里插入版權符號08
第一步打開我們電腦上的Dreamweaver,小編在這里新建一個網頁做樣例
第二步這回里先設置一下字體,方答便觀看效果
第三步在瀏覽器看了一下效果之後,我們點擊「插入->HTML->特殊字元->版權」
第四步在瀏覽器裡面觀看,可以看到已經插入版權符號了
第五步我們也可以網路搜索「html有用的字元實體」,直接將下面的復制到dreamweaver網頁裡面去
Ⅶ delphi單元有那些以及單元的作用
Borland出品的Delphi,有著閃電般的編譯速度,但是在界面控制項運用較多、工程項目較大的時分,編譯一個工程仍需求一段時間,翻開龐大的Delphi IDE,也需求時間。其實,在一個工程開拓完畢,調試完成之後的Release編譯,完整可以用命令行來實施,由於Delphi的編譯器參數不像C++編譯器那樣繁雜。 筆者把Delphi聯機手冊中關於命令行編譯(。mand-line 。piler)的幾篇主題作了翻譯,希冀對Delphi開拓人員有輔佐。 目錄 1。 Command-line 。piler 命令行編譯器 2。 Command-line 。piler options 命令行編譯器選項 3。 Compiler directive options 編譯器指令選項 4。 Compiler mode options 編譯形式選項 5。 DCC32。CFG file 編譯器配置文件DCC32。CFG 6。 Debug options 調試選項 7。 Directory options 目錄選項 8。 IDE 。mand-line options IDE命令行選項 9。 Generated files 幾個IDE自動生成的文件引見 Command-line 。piler 命令行編譯器 Delphi's 。mand-line 。piler (dcc32。EXE) lets you invoke all the functions of the IDE 。piler (DELPHI32。EXE) from the DOS 。mand line (see IDE 。mand-line options。 Run the 。mand-line 。piler from the DOS prompt using the syntax: Delphi』s命令行編譯器(dcc32。exe)容許你從DOS命令行方式(參照:IDE命令行選項)完成IDE編譯器(delphi32。exe)的一切功用。用DOS命令運轉命令行編譯器語法如下: dcc32 [options] filename [options] dcc32 [選項] [文件名] [選項] where options are zero or more parameters that provide 。rmation to the 。piler and filename is the name of the source file to 。pile。 If you type dcc32 alone, it displays a help screen of 。mand-line options and syntax。 零或多個參數給編譯器提供音訊,文件名指定需求編譯的源文件名。假設你獨自輸入dcc32,它會顯現一個關於命令行編譯的選項和語法的屏幕。 If filename does not have an extension, the 。mand-line 。piler assumes 。dpr, then 。pas, if no 。dpr is found。 If the file you're 。piling to doesn't have an extension, you must append a period (。) to the end of the filename。 假設文件名沒有擴展名,命令行編譯器會查找擴展名為。dpr的同名文件,假設找不到,則查找擴展名為。pas的同名文件。假設你的源文件確實沒有擴展名,你需求在文件名的開端增加(。)。 If the source text contained in filename is a program, the 。piler creates an executable file named filename。EXE。 If filename contains a library, the 。piler creates a file named filename。DLL。 If filename contains a package, the 。piler creates a file named filename。BPL。 If filename contains a unit, the 。piler creates a unit file named filename。dcu。 假設指定的源文件是一個工程文件,編譯器會創立一個擴展名為。EXE的同名可實施文件。假設指定的源文件是一個庫文件,編譯器創立一個擴展名為。DLL的同名靜態鏈接庫文件。假設指定的源文件是一個包文件,編譯器會創立一個擴展名為。BPL的同名包。假設指定的源文件是一個單元文件,編譯器會創立一個擴展名為。dcu的目的代碼文件。 You can specify a number of options for the 。mand-line 。piler。 An option consists of a slash (。) or immediately followed by an option letter。 In some cases, the option letter is followed by additional 。rmation, such as a number, a symbol, or a directory name。 Options can be given in any order and can 。e before or after the file name。 你可以為命令行編譯器指定多個參數。一個參數包括一個破折號「-」(或「。」)和緊跟著的一個選項字元形成。一般狀況下,選項字元前面會跟一些附加的音訊,如一個數字、一個符號、一個目錄等。選項可以是恣意次第並且可以在源文件名前面或前面。 Command-line 。piler options 命令行編譯選項 The IDE lets you set various options through the menus; the 。mand-line 。piler gives you access to these options using the slash (。) delimiter。 You can also precede options with a hyphen (-) instead of a slash (。), but those options that start with a hyphen must be separated by blanks。 For example, the following two 。mand lines are equivalent and legal: IDE容許你運用菜單來設置各種編譯選項,而命令行編譯器容許你運用字元「。」作為分隔符來設定這些編譯選項。你也可以運用連字元「-」來替代「。」,但是用「-」引出的參數之間必需用空格隔開。例如,下面兩個命令都是同等的也是合法的: DCC -IC:\DELPHI -DDEBUG SORTNAME -$R- -$U+ DCC 。IC:\DELPHI。DDEBUG SORTNAME 。$R-。$U+ The first 。mand line uses hyphens with at least one blank separating options。 The second uses slashes and no separation is needed。 第一個編譯命令用「-」引出參數,且參數之間有多個空格分隔。第二個編譯命令用「。」引出參數,參數之間不用要分隔。 The following table lists the 。mand-line options。 In addition to the listed options, all single-letter 。piler directives can be specified on the 。mand line, as described in Compiler directive options。 下列表中列出一切的命令行參數。在附加的選項列表中,一切的單字元編譯器指令都可以在命令行編譯中運用,概略請參照:編譯器指令。 Option Description 選項 描畫 Aunit=alias 設置單元別名 B 編譯一切單元 CC 編譯掌握台順序 CG 編譯圖形界面順序 Ddefines 編譯條件符號定義 Epath 可實施文件輸入途徑 Foffset 查找運轉時期過失 GD 生成完整。Map文件 GP 生成。Map文件Public段 GS 生成。Map文件Segment段 H 輸入提示音訊 Ipaths 文件包括途徑 J 生成。Obj目的文件 JP 生成C++類型。Obj目的文件 Kaddress Set image base address LEpath 包。BPL文件輸入途徑 LNpath 。dcp文件輸入途徑 LUpackage 運用運轉時期包列表 M 編譯有改動的源文件 Npath dcu。dpu文件輸入目錄 Opaths 。Obj文件(匯編目的代碼文件)途徑 P 按8。3格式文件名查找 Q 恬靜形式 Rpaths 資源文件(。RES)途徑 TXext 目的文件擴展名 Upaths 單元文件途徑 V 為Turbo Debugger生成調試音訊文件 VN 以。Giant格式生成包括命名空間的調試音訊文件(將用於C++Builder) VR 生成調試音訊文件。rsm W 輸入正告音訊 Z Disable implicit 。pilation $directive Compiler directives --Help 顯現編譯選項的輔佐。異樣的,假設你在命令行獨自輸入dcc32,也會顯現編譯選項的輔佐。 --version 顯現產品稱號和版本 Compiler directive options 編譯器指令選項 Delphi supports the 。piler directives described in Compiler directives。 The $ and D 。mand-line options allow you to change the default states of most 。piler directives。 Using $ and D on the 。mand line is equivalent to inserting the corresponding 。piler directive at the beginning of each source file 。piled。 Delphi支持用編譯器指令關鍵字描畫的編譯器指令。運用「$」和「D」命令行選項可以改動一切的默許編譯器形狀。用「$」和「D」命令行選項同等於在源文件的前面增加編譯器指令。 Switch directive option 編譯器指令選項開關 The $ option lets you change the default state of all of the switch directives。 The syntax of a switch directive option is $ followed by the directive letter, followed by a plus (+) or a minus (-)。 For example: 「$」容許你改動每一種編譯器指令默許形狀。編譯器指令的語法是「$」後緊跟一個指令字元,再跟一個「-」或「+」。例如: dcc32 MYSTUFF -$R- 。piles MYSTUFF。pas with range-checking turned off, while: 不運用邊境檢查編譯MYSTUFF。pas單元: dcc32 MYSTUFF -$R+ 。piles it with range checking turned on。 Note that if a {$R+} or {$R-} 。piler directive appears in the source text, it overrides the -$R 。mand-line option。 運用界面檢查編譯MYSTUFF。pas單元。假設將編譯器指令{$R+}或{$R-}增加到源文件的開端,它將掩蓋從命令行傳入的參數。 You can repeat the -$ option in order to specify multiple 。piler directives: 你可以用多個「$」來指定多個編譯器指令,如: dcc32 MYSTUFF -$R--$I--$V--$U+ Alternately, the 。mand-line 。piler lets you write a list of directives (except for $M), separated by 。mas: 命令行編譯器容許作用逗號分隔的編譯器指定列表,如: dcc32 MYSTUFF -$R-,I-,V-,U+ 只需求用一個「$」符號。 Only one dollar sign ($) is needed。 留意,由於$M的格式不一樣,你不能在逗號分隔的指令列表中運用$M Note that, because of its format, you cannot use the $M directive in a list of directives separated by 。mas。 Conditional defines option 條件編譯選項 The -D option lets you define conditional symbols, corresponding to the {$DEFINE symbol} 。piler directive。 The -D option must be followed by one or more conditional symbols separated by semicolons (;)。 For example, the following 。mand line: 「-D」選項容許你定義一個編譯條件,契合你用{$DEFINE symbol}定義的編譯器指令。「-D」選項後必需跟隨一或多個用分號分隔的編譯條件符號,如下命令: dcc32 MYSTUFF -DIOCHECK;DEBUG;LIST defines three conditional symbols, iocheck, debug, and list, for the 。pilation of MYSTUFF。pas。 This is equivalent to inserting: 定義了三個編譯條件符號:IOCHECK,DEBUG,LIST,用於MYSTUFF。pas單元中。這同等於在源文件中插入以下語句: {$DEFINE IOCHECK} {$DEFINE DEBUG} {$DEFINE LIST} at the beginning of MYSTUFF。pas。 If you specify multiple -D directives, you can concatenate the symbol lists。 Therefore: 假設你指定了多個「-D」選項,你可以銜接它們,如下: dcc32 MYSTUFF -DIOCHECK-DDEBUG-DLIST is equivalent to the first example。 同等於第一個例子。 Compiler mode options 編譯形式選項 A few options affect how the 。piler itself functions。 As with the other options, you can use these with either the hyphen or the slash format。 Remember to separate the options with at least one blank。 有幾個選項能影響編譯器自身的功用。像其它選項一個,你可以運用「。」或「-」的格式。別忘了用至少一個空格分隔這些選項。 Make (-M) option 選項(-M) The 。mand-line 。piler has built-in MAKE logic to aid in project maintenance。 The -M option instructs 。mand-line 。piler to check all units upon which the file being 。piled depends。 Using this option results in a much quicker 。pile time。 命令行編譯器運用結構邏輯的方式來維護工程。「-M」選項指示編譯器檢查一切與編譯文件相關聯的文件。用這個參數會招致編譯時間增大。 A unit is re。piled under the following conditions: 一個源文件在下列狀況下會重新編譯: The source file for that unit has been modified since the unit file was created。 源文件被創立以來被修正過; 用「$I」指令包括的任何文件,用「$L」包括的任何。Obj文件,或用「$R」關聯的任何資源文件。Res,比源文件中的要新; Any file included with the $I directive, any 。OBJ file linked in by the $L directive, or any 。res file referenced by the $R directive, is newer than the unit file。 The interface section of a unit referenced in a uses statement has changed。 單元介面局部interface的uses段有改動。 Units 。piled with the -Z option are excluded from the make logic。 在單元編譯時指令「-Z」在結構邏輯期不被接受。 If you were applying this option to the previous example, the 。mand would be: 假設你在上一個例子中運用這個指令,編譯命令就應當是: dcc32 MYSTUFF -M Build all (-B) option 編譯一切 選項(-B) Instead of relying on the -M option to determine what needs to be updated, you can tell 。mand-line 。piler to update all units upon which your program depends using the -B option。 You can't use -M and -B at the same time。 The -B option is slower than the -M option and is usually unnecessary。 用於取代要知道哪些單元需求更新-M的選項,你可以運用-B選項來更新一切你的順序中關聯的單元。你不能在順序中同時運用-M和-B。選項-B比-M速度更慢,而且它並不是必需的。 If you were using this option in the previous example, the 。mand would be 假設你在前一個例子中運用這個參數,編譯命令就應當是: dcc32 MYSTUFF -B Find error (-F) option 查找過失 選項(-F) When a program terminates e to a runtime error, it displays an error code and the address at which the error occurred。 By specifying that address in a -Faddress option, you can locate the statement in the source text that caused the error, provided your program and units were 。piled with debug 。rmation enabled (via the $D 。piler directive)。 當一個順序由於運轉時期過失而終止時,它會顯現一個過失號和過失地址在過失發生時。用-Faddress選項來指定過失地址,你在源文件中能找到引發過失的位置,假設你的順序和單元編譯時附加了調試音訊(運用$D編譯器指令)。 In order for the 。mand-line 。piler to find the runtime error with -F, you must 。pile the program with all the same 。mand-line parameters you used the first time you 。piled it。 為了命令行編譯器能用-F選項查找運轉時期過失,你必需傳遞與第一次編譯時相同的指令列表。 As mentioned previously, you must 。pile your program and units with debug 。rmation enabled for the 。mand-line 。piler to be able to find runtime errors。 By default, all programs and units are 。piled with debug 。rmation enabled, but if you turn it off, using a {$D-} 。piler directive or a -$D- option, the 。mand-line 。piler will not be able to locate runtime errors。 先前提到過,你的順序和單元必需啟用調試音訊,命令行編譯器才幹查找運轉時期過失。默許狀況下,一切的順序和單都是啟用調試音訊的,除非你用{-D}或-$D-指令封鎖它,這樣,命令行編譯器就不能查找運轉時期過失了。 Use packages (-LU) option 運用包(-LU)選項 Use the -LU option to list additional runtime packages that you want to use in the application being 。piled。 Runtime packages already listed in the Project Options dialog box need not be repeated on the 。mand line。 運用-LU選項來在編譯時增加你運用順序中要用到的運轉時期包。運轉時期包曾經在「工程選項」對話框中羅列的,不用再在命令行中增加。 Disable implicit 。pilation (-Z) option (此選項在delphi6。0。7。0中有不同描畫,在此不作翻譯) The -Z option prevents packages and units from being implicitly re。piled later。 With packages, it is equivalent to placing {$ IMPLICITBUILD OFF} in the 。dpk file。 Use -Z when 。piling packages that provide low-level functionality, that change infrequently between builds, or whose source code will not be distributed。 Target file extension (-TX) option 目的文件擴展名(-TX)選項 The -TX option lets you override the default extension for the output file。 For example, 選項-TX容許你改寫默許的輸入文件擴展名。例如: dcc32 MYSTUFF -TXSYS generates 。piled output in a file called MYSTUFF。SYS。 生成的將是一個叫做MYSTUFF。SYS的文件。 Quiet (-Q) option 恬靜形式(-Q)選項 The quiet mode option suppresses the printing of file names and line numbers ring 。pilation。 When the 。mand-line 。piler is invoked with the quiet mode option 恬靜形式選項制止在編譯時顯現文件名及代碼行數,假設命令行編譯器調用這個選項的話。 dcc32 MYSTUFF -Q its output is limited to the startup right message and the usual statistics at the end of 。pilation。 If any errors occur, they will be reported。 它的輸入僅限於起始時行版權音訊以及開頭的統計音訊。當然,假設發生過失,它也會輸入。 DCC32。CFG file DCC32。CFG配置文件 You can set up a list of options in a configuration file called DCC32。CFG, which will then be used in addition to the options entered on the 。mand line。 Each line in configuration file corresponds to an extra 。mand-line argument inserted before the actual 。mand-line arguments。 Thus, by creating a configuration file, you can change the default setting of any 。mand-line option。 你可以設置一個編譯選項列表到一個叫做DCC32。CFG的配置文件中,它將用於編譯時附加到命令行參數後。配置文件的每一行都相當於一個額外的命令行參數插入到實踐的命令行參數前(留意,是實踐參數前)。因此,你可以運用這個配置文件改動一些命令行參數的默許設置。 The 。mand-line 。piler lets you enter the same 。mand-line option several times, ignoring all but the last occurrence。 This way, even though you've changed some settings with a configuration file, you can still override them on the 。mand line。 命令行編譯器容許你輸入相同的命令行參數,它將疏忽一切除最後一個之外。這個的話,固然經過配置文件你可以改動一些設置,你依然可以掩蓋它運用命令行參數。 When dcc32 starts, it looks for DCC32。CFG in the current directory。 If the file isn't found there, dcc32 looks in the directory where DCC32。EXE resides。 當dcc32發起時,它查找DCC32。CFG文件在以後目錄。假設文件沒有找到,dcc32會查找它所在的目錄。 Here's an example DCC32。CFG file, defining some default directories for include, object, and unit files, and changing the default states of the $O and $R 。piler directives: 以下是一個DCC32。CFG配置文件的例子,定義了關於文件包括、OBJ文件包括、單元文件搜尋途徑音訊,並改動了編譯器指令$O和$R的默許值。 -IC:\DELPHI\INC;C:\DELPHI\SRC -OC:\DELPHI\ASM -UC:\DELPHI\UNITS -$R+ -$O- Now, if you type: 往常,假設你輸入: dcc32 MYSTUFF the 。piler performs as if you had typed the following: 編譯器把它當作你輸入如下命令: dcc32 -IC:\DELPHI\INC;C:\DELPHI\SRC -OC:\DELPHI\ASM -UC:\DELPHI\UNITS -$R+ -$O- MYSTUFF Debug options 調試選項 The 。piler has two sets of 。mand-line options that enable you to generate external debugging 。rmation: the map file options and the debug 。 options。 編譯器有兩個命令行參數可以生成外部調試音訊:MAP文件選項和調試音訊選項。 Map file (-G) options Map文件(-G)選項 The -G option instructs the 。mand-line 。piler to generate a 。map file that shows the layout of the executable file。 Unlike the binary format of executable and 。dcu files, a 。map file is a legible text file that can be output on a printer or loaded into the editor。 The -G option must be followed by the letter S, P, or D to indicate the desired level of 。rmation in the 。map file。 A 。MAP file is divided into three sections: 選項-G指示命令行編譯器生成一個。map文件來檢查一個可實施文件的布局。不同於可二進制的可實施文件和。dcu文件,。map文件是一個可讀的文本文件,可以被列印或是其它文本編輯器編輯。選項-G後必需跟字元S、P或D,去決議你想要在。map文件列出的音訊。一個。MAP文件被分紅三個節: Segment Publics Line Numbers -GS outputs only the Segment section, -GP outputs the Segment and Publics section, and -GD outputs all three sections。 -GD also generates a 。DRC file that contains tables of all string constants declared using the resourcestring keyword。 -GS選項只輸入Segment Section,-GS選項輸入Segment和Publics,-GD輸入一切的三個Sections。-GD選項也生成一個擴展名為。DRC的文件包括一切的用resourcestring關鍵字聲明的字元串常量。 For moles (program and units) 。piled in the {$D+,L+} state (the default), the Publics section shows all global variables, proceres, and functions, and the Line Numbers section shows line numbers for all proceres and functions in the mole。 In the {$D+,L-} state, only symbols defined in a unit's interface part are listed in the Publics section。 For moles 。piled in the {$D-} state, there are no entries in the Line Numbers section。 用默許的編譯選項{$D+,L+}編譯模塊(順序或單元),Publics Section羅列一切的全局變數、進程和函數,Line Numbers Section羅列模塊中一切的進程和函數的行號。假設用{$D+,L-}編譯選項編譯模塊,Publics Section中僅羅列在單元的interface局部定義的符號。假設用{$D-}選項編譯模塊,在Line Numbers Section沒有任何入口。 Debug 。 (-V) options 布置選項(-V) The -V options (-V, -VN。 and -VR), which cause the 。piler to generate debug 。rmation, can be 。bined on the 。mand line。 選項-V、-VN、-VR會指示編譯器生成調試音訊,它們能在命令行中組合運用。 Generate Turbo Debugger debug 。 (-V) option 生成Turbo Debugger運用的調試音訊的選項(-V) When you specify the -V option on the 。mand line, the 。piler appends Turbo Debugger 5。0-。patible external debug 。rmation at the end of the executable file。 Turbo Debugger includes both source- and machine-level debugging and powerful breakpoints。 當你在命令行中運用-V選項時,編譯器會在可實施文件的開端附加與Turbo Debugger5。0一致的外部調試音訊。Turbo Debugger包括代碼和硬體級別的弱小的斷點。 Even though the debug 。rmation generated by -V makes the resulting executable file larger, it does not affect the actual code in the executable, and does not require additional memory to run the program。 固然附加調試音訊到查實施文件中會使可實施文件增大,但是它並不影響實踐可實施文件中的可實施代碼,也不需求額外的內存來發起順序。 The extent of debug 。rmation appended to the executable file depends on the setting of the $D and $L 。piler directives in each of the moles (program and units) that make up the application。 For moles 。piled in the {$D+,L+} state, which is the default, all constant, variable, type, procere, and function symbols are known to the debugger。 In the {$D+,L-} state, only symbols defined in a unit's interface section are known to the debugger。 In the {$D-} state, no line-number records are generated, so the debugger cannot display source lines whe 2011-10-24 7:49:57