用Delphi6 ,编写一段相互嵌套的程序,但是总是一些我看不懂的错误。还有我是刚刚学习Delphi ,请教高手!
{/********所有程序*************/}unitNesting;interfaceusesWindows,Messages,SysUtils,Varia...
{/********所有程序*************/}
unit Nesting;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{/*****************************************/}
var
Alpha :Integer;
procedure Test2(var A:Integer):forword; //forword关键字,说明Test2为前置过程
{/***** Test1、Test2相互嵌套*******/}
procedure Test1(var A:Integer);
begin
A:=A-1;
// Dec(A);
if A>0 then
Test2(A);
Memo1.Text := IntToStr(A); //输出当前的A值
end;
procedure Test2(var A:Integer);
begin
A:=A div 2;
if A>0 then
Test1(A);
end;
{/****************************************/}
procedure TForm1.Button1Click(Sender: TObject);
begin
Alpha :=15;
Test1(Alpha);
end;
end.
{/***************编译报的错误**************/}
[Error] Nesting.pas(29): Undeclared identifier: 'forword'
[Error] Nesting.pas(37): Undeclared identifier: 'Memo1'
[Error] Nesting.pas(37): '(' expected but ':=' found
[Error] Nesting.pas(47): ';' expected but '.' found
[Error] Nesting.pas(53): ';' expected but '.' found
[Error] Nesting.pas(56): Declaration expected but end of file found
[Error] Nesting.pas(13): Unsatisfied forward or external declaration: 'TForm1.Button1Click'
[Fatal Error] nesting1.dpr(5): Could not compile used unit 'Nesting.pas' 展开
unit Nesting;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{/*****************************************/}
var
Alpha :Integer;
procedure Test2(var A:Integer):forword; //forword关键字,说明Test2为前置过程
{/***** Test1、Test2相互嵌套*******/}
procedure Test1(var A:Integer);
begin
A:=A-1;
// Dec(A);
if A>0 then
Test2(A);
Memo1.Text := IntToStr(A); //输出当前的A值
end;
procedure Test2(var A:Integer);
begin
A:=A div 2;
if A>0 then
Test1(A);
end;
{/****************************************/}
procedure TForm1.Button1Click(Sender: TObject);
begin
Alpha :=15;
Test1(Alpha);
end;
end.
{/***************编译报的错误**************/}
[Error] Nesting.pas(29): Undeclared identifier: 'forword'
[Error] Nesting.pas(37): Undeclared identifier: 'Memo1'
[Error] Nesting.pas(37): '(' expected but ':=' found
[Error] Nesting.pas(47): ';' expected but '.' found
[Error] Nesting.pas(53): ';' expected but '.' found
[Error] Nesting.pas(56): Declaration expected but end of file found
[Error] Nesting.pas(13): Unsatisfied forward or external declaration: 'TForm1.Button1Click'
[Fatal Error] nesting1.dpr(5): Could not compile used unit 'Nesting.pas' 展开
1个回答
展开全部
1、[Error] Nesting.pas(29): Undeclared identifier: 'forword' 未知的标识符 forword delphi中并没有这个关键字,不知道你从何而来 forward 到是有这个
procedure Test2(var A:Integer):forword;
这句的声明不应该是放在 implementation 关键字后面,而是放在前面,或者放在private
或public下面
2、[Error] Nesting.pas(37): Undeclared identifier: 'Memo1' 未知的标识符
procedure Test1(var A:Integer);
begin
A:=A-1;
// Dec(A);
if A>0 then
Test2(A);
Memo1.Text := IntToStr(A); //出错在这里必须要加当前窗口名
//正确这样
Form1.Memo2.Text := IntToStr(A);
end;
后面几个就不解释了,自己多看看基础吧
procedure Test2(var A:Integer):forword;
这句的声明不应该是放在 implementation 关键字后面,而是放在前面,或者放在private
或public下面
2、[Error] Nesting.pas(37): Undeclared identifier: 'Memo1' 未知的标识符
procedure Test1(var A:Integer);
begin
A:=A-1;
// Dec(A);
if A>0 then
Test2(A);
Memo1.Text := IntToStr(A); //出错在这里必须要加当前窗口名
//正确这样
Form1.Memo2.Text := IntToStr(A);
end;
后面几个就不解释了,自己多看看基础吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询