请看下列代码有问题的那一行。(50分)

  • 主题发起人 主题发起人 xuyingfeng
  • 开始时间 开始时间
X

xuyingfeng

Unregistered / Unconfirmed
GUEST, unregistred user!
编译时老师再有问题的那一行出现
[Error] ysbddl_Unit.pas(22): Unsatisfied forward or external declaration: 'Tysbddl_frm.CSktXOnConnect'
unit ysbddl_Unit;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ScktComp, StdCtrls, Buttons, ExtCtrls, Menus, CSkt;

type
Tysbddl_frm = class(TForm)
Panel1: TPanel;
Memo2: TMemo;
Panel2: TPanel;
BitBtn1: TBitBtn;
Memo1: TMemo;
ListBox1: TListBox;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
sskt1: TServerSocket;
ClientSocket1: TClientSocket;
有问题的行: procedure CSktXOnConnect(Sender: TObject;Socket: TCustomWinSocket);
procedure CSktXOnError(sender: TObject; Socket: TCustomWinSocket;ErrorEvent: TErrorEvent; var ErrorCode: Integer);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
ysbddl_frm: Tysbddl_frm;
CSktX:array[0..299] of TClientSocket;
implementation

uses ysbddl_dm_Unit;

{$R *.DFM}

procedure Tysbddl_frm.BitBtn1Click(Sender: TObject);
var i:integer;
begin
i:=0;
with ysbddl_dm.ysbddl_spc1 do
begin
params[0].asstring:=memo2.text;
prepare;
execproc;
ysbddl_dm.ysbddl_spc1.close;
end;
with ysbddl_dm.computer_ip_qry do
begin
open;
first;
repeat
CSktx:=TClientSocket.create(self);
CSktx.OnConnect:=CSktXOnConnect;
CSktx.OnError:=CSktXOnError;
CSktx.address:=fieldbyname('cop_ip').asstring;
CSktx.Port:=75555;
CSktx.Active:=true;
i:=i+1;
next;
until eof;
end;
end;
procedure CSktOnConnect(Sender: TObject;Socket: TCustomWinSocket);
begin
socket.SendText('(^%^)start'+ysbddl_frm.memo2.text+'(^%^)end');
ysbddl_frm.memo1.lines.add(socket.remoteaddress+'在"'+socket.RemoteHost+'"上的计算机已经接收到调令');
end;
procedure CSktOnError(sender: TObject; Socket: TCustomWinSocket;ErrorEvent: TErrorEvent; var ErrorCode: Integer);
begin
errorcode:=0;
//ysbddl_frm.memo1.lines.add(address+'在"'+Host+'"上的计算机没有接收到调令');
end;


end.
 
这里续称的是一个TClientSocket的onconnect和onerror事件
是不是续称方法不对?
 
对不起各位问题已解决!!!因为少加了Tysbddl_frm.
 
procedure CSktXOnConnect(Sender: TObject;Socket: TCustomWinSocket);对应的
实现文件应写成
procedure Tysbddl_frm.CSktXOnConnect(Sender: TObject;Socket: TCustomWinSocket);
你少写了"Tysbddl_frm.",系统以为是全局过程,但你声明的过程是属于Tysbddl_frm类的。

哈哈!快点给我分吧!
 
兄弟,看仔细一点吧:
有问题的代码中
procedure CSktXOnConnect(Sender: TObject;Socket: TCustomWinSocket);
在implementation里,你却这样写:
procedure CSktOnConnect(Sender: TObject;Socket: TCustomWinSocket);

一个是CSktXOnConnect,一个是CSktOnConnect(少了个X),编译器当然认为
csktxonconnect没有相对应的implementation说明了^_^)
 
另外:csgcsw说的也对,这两个玩意儿改正后
就对了,哈哈!
 
多人接受答案了。
 
后退
顶部