codegear delphi2007 win32中procedure或function宣告有改變嗎? |
答題得分者是:pedro
|
mitchellhu
一般會員 ![]() ![]() 發表:23 回覆:53 積分:15 註冊:2007-06-12 發送簡訊給我 |
一、我是使codegear delphi2007 win32版本,寫了下面的程式碼,我主要問題是codegear delphi2007 win32中procedure或function宣告`為公開使用的位置是否有更改,我記得應是放在type的下面。我的程式碼,在編譯時會報錯。錯誤訊息是:[DCC Error] Unit1.pas(11): E2065 Unsatisfied forward or external declaration: 'TForm1.ValPro'
二、按F1查看E2065的意義如下:This error message appears when you have a forward or external declaration of a procedure or function, or a declaration of a method in a class or object type, and you don't define the procedure, function or method anywhere. Maybe the definition is really missing, or maybe its name is just misspelled. Note that a declaration of a procedure or function in the interface section of a unit is equivalent to a forward declaration - you have to supply the implementation (the body of the procedure or function) in the implementation section. Similarly, the declaration of a method in a class or object type is equivalent to a forward declaration. 三、看這語意是說我的procdure是forward或external宣告。而且要在implementatation段實作。我看我的程式碼是合於所述。真得有點摸不著頭緒了。請各位先進給予一些指導。謝謝 四、程式碼如下:(其中procedure ValPro 要準備要unit2引用的) unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure ValPro(X: Integer; Y:String); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation procedure ValPro(X: Integer; Y:String); var A : Integer; begin A := 0; repeat A := A 1; Form1.Canvas.TextOut(140,120 20*(A-1),'過程' IntToStr(A) '' Y); until X <= A; end; {$R *.dfm} end. |
pedro
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:152 回覆:1187 積分:892 註冊:2002-06-12 發送簡訊給我 |
|
mitchellhu
一般會員 ![]() ![]() 發表:23 回覆:53 積分:15 註冊:2007-06-12 發送簡訊給我 |
|
mitchellhu
一般會員 ![]() ![]() 發表:23 回覆:53 積分:15 註冊:2007-06-12 發送簡訊給我 |
===================引 用 Ktop_Robot 文 章=================== 提問者您好: 以上回應是否已得到滿意的答覆? 若已得到滿意的答覆,請在一週內結案,否則請在一週內回覆還有什麼未盡事宜,不然, 將由版主(尚無版主之區域將由副站長或站長)採自由心證,選擇較合適之解答予以結案處理, 被選上之答題者同樣會有加分獎勵,同時發問者將受到扣 1 分的處分。不便之處,請見諒。 有問有答有結案,才能有良性的互動,良好的討論環境需要大家共同維護,感謝您的配合。 報告副版主大人: 我已按了結案鈕了,是系統好像沒動作,請幫忙看看。感謝 |
SmallBare
一般會員 ![]() ![]() 發表:2 回覆:11 積分:2 註冊:2003-10-20 發送簡訊給我 |
|
sryang
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:39 回覆:762 積分:920 註冊:2002-06-27 發送簡訊給我 |
看樣子,你是完全自己 key in 程式碼的吧。包含宣告與實做。
難怪會發生這種錯誤 往後你就先 key in 好宣告,然後按下 Ctrl-Shift-C,或是按滑鼠右鍵,選擇 Complete Class at Cursor,就會產生實做部份的宣告 反過來,如果先 key in 好實做,然後按下 Ctrl-Shift-C,一樣會產生宣告部份。 舉例: 程式列表一: interface uses classes; TClass1 = class private procedure Foo(i: integer); // <按下 Ctrl-Shift-C> public end; implementation end. 就會變成: interface uses classes; TClass1 = class private procedure Foo(i: integer); // <按下 Ctrl-Shift-C> public end; implementation procedure TClass1.Foo(i: integer); begin end; end.
------
歡迎參訪 "腦殘賤貓的備忘錄" http://maolaoda.blogspot.com/
編輯記錄
sryang 重新編輯於 2007-07-20 12:04:14, 註解 無‧
|
mitchellhu
一般會員 ![]() ![]() 發表:23 回覆:53 積分:15 註冊:2007-06-12 發送簡訊給我 |
我確實自已手動code好的,因為宣告format的誤解才產生問題。
這2天已確實明白宣告的format,並已實作procedure, functin 和class的宣告及implemation段的實作。 也試過快捷鍵的自動產生宣告/implemation段宣告。 說真心話Codeger Delphi2007 win32 IDE真的蠻貼心,會聰明的去幫coding人員自動補上欠缺的code。 以前純手工打造code的方式真的改變了,真的要認的去try 才有能力編碼。 anyway 感謝2位的回覆和指導,哈哈。但結案分數好像只能給一個人(有點頭痛),這次就先給Pedro75091大老了。 |
sryang
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:39 回覆:762 積分:920 註冊:2002-06-27 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |