这段程序为什么不能通过?

delfans 2001-07-09 12:20:58
这个过程是参考DELPHI6帮助文件中的示例写的,但不通过,提示:

[Warning] Unit3.pas(49): Symbol 'FileGetAttr' is specific to a platform
[Warning] Unit3.pas(49): Symbol 'faReadOnly' is specific to a platform
[Warning] Unit3.pas(49): Symbol 'faReadOnly' is specific to a platform
[Warning] Unit3.pas(49): Symbol 'faArchive' is specific to a platform
[Warning] Unit3.pas(49): Symbol 'faArchive' is specific to a platform
[Warning] Unit3.pas(49): Symbol 'faSysFile' is specific to a platform
[Warning] Unit3.pas(49): Symbol 'faSysFile' is specific to a platform
[Warning] Unit3.pas(49): Symbol 'faHidden' is specific to a platform
[Warning] Unit3.pas(49): Symbol 'faHidden' is specific to a platform
[Warning] Unit3.pas(49): Symbol 'faReadOnly' is specific to a platform
[Error] Unit3.pas(49): Missing operator or semicolon
[Error] Unit3.pas(49): Statement expected, but expression of type 'Integer' found
[Warning] Unit3.pas(49): Symbol 'faArchive' is specific to a platform
[Error] Unit3.pas(49): Missing operator or semicolon
[Error] Unit3.pas(49): Statement expected, but expression of type 'Integer' found
[Warning] Unit3.pas(49): Symbol 'faSysFile' is specific to a platform
[Error] Unit3.pas(49): Missing operator or semicolon
[Error] Unit3.pas(49): Statement expected, but expression of type 'Integer' found
[Warning] Unit3.pas(49): Symbol 'faHidden' is specific to a platform
[Error] Unit3.pas(49): Missing operator or semicolon
[Error] Unit3.pas(49): Statement expected, but expression of type 'Integer' found
[Warning] Unit3.pas(49): Symbol 'FileSetAttr' is specific to a platform
[Error] Unit3.pas(49): Undeclared identifier: 'FileDirName'
[Error] Unit3.pas(49): Not enough actual parameters
[Error] Unit3.pas(49): '.' expected but ';' found
[Fatal Error] Project1.dpr(8): Could not compile used unit 'Unit3.pas'


过程代码:
procedure TForm3.FormShow(Sender: TObject);
var
Attributes, NewAttributes: Word;
begin
if Form1.Edit1.Text='*.*' then
begin
showmessage('请选择一个文件!');
close;
end
else
begin
Attributes := FileGetAttr(Form1.FileListBox1.FileName);
chkReadOnly.Checked := (Attributes and faReadOnly) = faReadOnly;
chkArchive.Checked := (Attributes and faArchive) = faArchive;
chkSystem.Checked := (Attributes and faSysFile) = faSysFile;
chkHidden.Checked := (Attributes and faHidden) = faHidden;

{ 如果屏蔽掉这部分就可以通过

if ShowModal <> id_Cancel then
begin
NewAttributes := Attributes;
if chkReadOnly.Checked then
NewAttributes := NewAttributes or faReadOnly
else
NewAttributes := NewAttributes andnot faReadOnly;
if chkArchive.Checked then
NewAttributes := NewAttributes or faArchive
else
NewAttributes := NewAttributes andnot faArchive;
if chkSystem.Checked then
NewAttributes := NewAttributes or faSysFile
else
NewAttributes := NewAttributes andnot faSysFile;
if chkHidden.Checked then
NewAttributes := NewAttributes or faHidden
else
NewAttributes := NewAttributes andnot faHidden;
if NewAttributes <> Attributes then
FileSetAttr(FileDirName.Caption, NewAttributes);
end;
}

end;

end;

恳请各位给予指点
...全文
183 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
vive 2001-07-10
  • 打赏
  • 举报
回复
这个警告是告诉你,这个过程是平台相关的,你用这个就不能跨平台了
lwk_hlj 2001-07-10
  • 打赏
  • 举报
回复
你没有一些引用文件
C_Sharp 2001-07-09
  • 打赏
  • 举报
回复
if ShowModal <> id_Cancel then 这句是不是有问题
windindance 2001-07-09
  • 打赏
  • 举报
回复
奇怪,我测试没有问题呀?
program aaa;
uses
sysutils,dialogs;
var
Attributes,NewAttributes:integer;
begin
Attributes := FileGetAttr('e:\\1.dat');
NewAttributes := Attributes OR faReadOnly;
showmessage(inttostr( NewAttributes));
end.
jbtan 2001-07-09
  • 打赏
  • 举报
回复
我测试了你的程序,除了andnot,还得加上use FileCtrl;
delphi6支持跨平台,所以多了些编译指令和提示。
例如:
procedure TForm3.FormShow(Sender: TObject);platform;
可以去掉[warning]
delfans 2001-07-09
  • 打赏
  • 举报
回复
试来试去还是不行啊
delfans 2001-07-09
  • 打赏
  • 举报
回复
试过把andnot改成and not了,还是不行
另外d6的帮助文件里确实写的andnot
jbtan 2001-07-09
  • 打赏
  • 举报
回复
and not, NOT andnot
Check help file for platform infomation.
delfans 2001-07-09
  • 打赏
  • 举报
回复
to zhengji
我原来是把上面的代码分成两个过程,一个读取文件属性,一个更新文件属性,前一个没问题,
但后一个出现上面的错误提示,后来参考d6的帮助文件改成现在这个样子,还是不幸
blucecat 2001-07-09
  • 打赏
  • 举报
回复
Symbol 'FileGetAttr' is specific to a platform------警告,无所谓了
delfans 2001-07-09
  • 打赏
  • 举报
回复
我的user部分如下

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

其实我也怀疑是引用少了哪个文件,但不明白为什么屏蔽掉后面那段代码就没事了呢
DreamTiger 2001-07-09
  • 打赏
  • 举报
回复
把你的uses列出来,估计是引用的文件不对。d6中引用文件特别要注意,呵呵。
zhengji 2001-07-09
  • 打赏
  • 举报
回复
delfans 你是不是想在用户选 ok 后改 文件的属性,
在用户选 cancel 后不更改属性啊 ??
要是这样的话,我觉得应该在显示 form3 函数里处理,如上所述,ok?
  • 打赏
  • 举报
回复
不会是你没有引用哪个单元文件吧?
zhengji 2001-07-09
  • 打赏
  • 举报
回复
看你的意思 是不是应该这样啊:
procedure TForm1.Button1Click(Sender: TObject);
var
...
...
begin
if form2.ShowModal <> id_Cancel then //你注释掉的代码
begin
...
...
end;
end;
delfans 2001-07-09
  • 打赏
  • 举报
回复
请问
Symbol 'FileGetAttr' is specific to a platform
这句是什么意思?

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧