注册 登录
编程论坛 Delphi论坛

[求助]DELPHI的编译问题

cch8080 发布于 2007-07-01 10:31, 1560 次点击

小弟是个刚学DELPHI的菜鸟,今天根据课本的一个编程例子来做了个程序,代码如下:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;

type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
sr:tsearchrec;
fileattrs:integer;
begin
stringgrid1.Rowcount:=1;
if checkbox1.Checked then
fileattrs:=fareadonly
else
fileattrs:=0;

if checkbox2.Checked then
fileattrs:=fileattrs+fahidden;

if checkbox3.Checked then
fileattrs:=fileattrs+fasysfile;

if checkbox4.Checked then
fileattrs:=fileattrs+favolumeid;

if checkbox5.Checked then
fileattrs:=fileattrs+fadirectory;

if checkbox6.Checked then
fileattrs:=fileattrs+faarchive;

if checkbox7.Checked then
fileattrs:=fileattrs+faanyfile;
with stringgrid1 do
begin
rowcount:=0;
if findfirst(edit1.text,fileattrs,sr) - 0 then
begin
cells(1,0):='文件名';
cells(2,0):='大小(K)';

repeat
if(sr.attr and fileattrs)=sr.attr then
begin
rowcount:=rowcount+1;
cells(1,rowcount-1):=sr.Name;
cells(2,rowcount-1):=inttostr(SR.Size);
end;
UNIT findnext(sr)<>0;
findclose(sr);
end;
end;
end;

end.
可编译时老是出现下面的错误提示:
[Warning]Unit1.pas(43):Symbol'faReadOnly'is specific to a platform
[Warning]Unit1.pas(48):Symbol'faHidden'is specific to a platform
[Warning]Unit1.pas(51):Symbol'faSysFile'is specific to a platform
[Warning]Unit1.pas(54):Symbol'faVolumeID'is specific to a platform
[Warning]Unit1.pas(60):Symbol'faArchive'is specific to a platform
[Error]Unit1.pas(67):Type of expression must be BOOLEAN
[Error]Unit1.pas(69):'['expected but '('found
[Error]Unit1.pas(70):'['expected but '('found
[Error]Unit1.pas(70):lllegal character in input file:';'($A3BB)
[Error]Unit1.pas(72):Missing operator or semicolon
[Error]Unit1.pas(76):'['expected but '('found
[Error]Unit1.pas(76):Left side cannot be assigned to
[Error]Unit1.pas(77):'['expected but '('found
[Error]Unit1.pas(77):Left side cannot be assigned to
[Error]Unit1.pas(79):Statement expected but 'UNIT'found
[Error]Unit1.pas(79):Statement expected,but expression of type 'Boolean'found
[Error]Unit1.pas(81):'UNTIL'expected but 'END' found
[Fatal Error]Project1.dpr(5):Could not compile used unit'Unit1.pas'
这是为什么呀,请各位高手帮忙看看,小弟在这先谢过大家了

1 回复
#2
anthony6342007-07-02 11:28

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
sr:tsearchrec;
fileattrs:integer;
begin
// stringgrid1.Rowcount:=1;
fileattrs:=0;
// MyRowCount:= 0;
{$WARN SYMBOL_PLATFORM OFF}
if checkbox1.Checked then
fileattrs:=fareadonly ;
// ;

if checkbox2.Checked then
fileattrs:=fileattrs+fahidden;


if checkbox3.Checked then
fileattrs:=fileattrs+fasysfile;


if checkbox4.Checked then
fileattrs:=fileattrs+favolumeid;

if checkbox6.Checked then
fileattrs:=fileattrs+faarchive;
{$WARN SYMBOL_PLATFORM ON}

if checkbox5.Checked then
fileattrs:=fileattrs+fadirectory; //

if checkbox7.Checked then
fileattrs:=fileattrs+faanyfile;
with stringgrid1 do
begin

if findfirst(edit1.text,fileattrs,sr) = 0 then
begin
cells[1,0]:='文件名';
cells[2,0]:='大小(K)';
rowcount:=1;
repeat
if(sr.attr and fileattrs)=sr.attr then
begin
cells[1,rowcount]:=sr.Name;
cells[2,rowcount]:=inttostr(SR.Size);
rowcount := rowcount + 1;
end;
until
findnext(sr) <> 0;
findclose(sr);
end;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Text := 'f:\*.*';
end;

end.

1