線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2212
推到 Plurk!
推到 Facebook!

codegear delphi2007 win32中procedure或function宣告有改變嗎?

答題得分者是:pedro
mitchellhu
一般會員


發表:23
回覆:53
積分:15
註冊:2007-06-12

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-07-17 17:58:47 IP:59.125.xxx.xxx 訂閱
一、我是使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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-07-17 18:20:53 IP:60.248.xxx.xxx 未訂閱
少了紅色字 
procedure TForm1.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.
mitchellhu
一般會員


發表:23
回覆:53
積分:15
註冊:2007-06-12

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-07-18 14:42:37 IP:59.125.xxx.xxx 訂閱
感謝Pedro75091大老的指導,問題已解決。 看來要快點搞清楚Delphi function,procedure,class,objects 的私有和公開宣告的相關準則,才不會浪費時間。 感恩。
mitchellhu
一般會員


發表:23
回覆:53
積分:15
註冊:2007-06-12

發送簡訊給我
#4 引用回覆 回覆 發表時間:2007-07-20 00:27:45 IP:211.74.xxx.xxx 訂閱

===================引 用 Ktop_Robot 文 章===================
提問者您好:


以上回應是否已得到滿意的答覆?


若已得到滿意的答覆,請在一週內結案,否則請在一週內回覆還有什麼未盡事宜,不然,
將由版主(尚無版主之區域將由副站長或站長)自由心證,選擇較合適之解答予以結案處理,
被選上之答題者同樣會有加分獎勵同時發問者將受到扣 1 分的處分。不便之處,請見諒。


有問有答有結案,才能有良性的互動,良好的討論環境需要大家共同維護,感謝您的配合。

報告副版主大人:
我已按了結案鈕了,是系統好像沒動作,請幫忙看看。感謝

SmallBare
一般會員


發表:2
回覆:11
積分:2
註冊:2003-10-20

發送簡訊給我
#5 引用回覆 回覆 發表時間:2007-07-20 11:20:31 IP:220.130.xxx.xxx 訂閱
左上 下拉式選單(在結案按鈕旁邊) 點選得分者在按結案試試
sryang
尊榮會員


發表:39
回覆:762
積分:920
註冊:2002-06-27

發送簡訊給我
#6 引用回覆 回覆 發表時間:2007-07-20 12:01:49 IP:59.125.xxx.xxx 訂閱
看樣子,你是完全自己 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

發送簡訊給我
#7 引用回覆 回覆 發表時間:2007-07-20 17:25:00 IP:59.125.xxx.xxx 訂閱
我確實自已手動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

發送簡訊給我
#8 引用回覆 回覆 發表時間:2007-07-28 01:29:38 IP:124.10.xxx.xxx 訂閱
Complete class at cursor 不是新功能喔,Delphi 5 就已經有了呢
之前的版本有沒有就不知道了
------
歡迎參訪 "腦殘賤貓的備忘錄" http://maolaoda.blogspot.com/
系統時間:2024-05-03 8:55:59
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!