下面怎么会这样的
[Warning] MAIN.PAS(239): Unsafe code 'BlockRead'[Warning] MAIN.PAS(413): Return value of function 'TMainForm.FormHelp' might be undefined我用BlockRead读文件,还有一个跟随式帮助,按F1帮助没有出来,但HelpContext是设置1的
//比较密码函数,s1:用户名,s2:密码,若比较成功,返回真
function TMainForm.CmpPassword(s1:string;s2:string):boolean;
var
datafile:file;
rt:boolean;
NumRead,teL,teN,ii:integer;
buf1,buf2,buf3:string[30];
begin
rt:=FALSE;
assignFile(datafile,'SYS.INI');
Reset(datafile,1); //打开配置文件
repeat
BlockRead(datafile,buf1,12,NumRead); //读用户名
BlockRead(datafile,buf2,12,NumRead); //读取密码
BlockRead(datafile,buf3,24,NumRead); //读权限
teL:=Length(buf2);
for ii:=1 to teL do //字符串加密
begin
teN:=NOT Ord(buf2[ii]);
buf2[ii]:=Chr(teN);
end;
if (s1=buf1)and(s2=buf2) then
begin
UserName:=s1;
UserPass:=s2;
if buf3[0]='^' then superPower:=True; //置权限
if buf3[1]='^' then userPower1:=True;
if buf3[2]='^' then userPower2:=True;
if buf3[3]='^' then userPower3:=True;
Result:=TRUE;
exit;
end;
until(NumRead=0);
closefile(datafile);
CmpPassword:=rt;
end;
[Warning] MAIN.PAS(239): Unsafe code 'BlockRead'[Warning] MAIN.PAS(413): Return value of function 'TMainForm.FormHelp' might be undefined我用BlockRead读文件,还有一个跟随式帮助,按F1帮助没有出来,但HelpContext是设置1的
//比较密码函数,s1:用户名,s2:密码,若比较成功,返回真
function TMainForm.CmpPassword(s1:string;s2:string):boolean;
var
datafile:file;
rt:boolean;
NumRead,teL,teN,ii:integer;
buf1,buf2,buf3:string[30];
begin
rt:=FALSE;
assignFile(datafile,'SYS.INI');
Reset(datafile,1); //打开配置文件
repeat
BlockRead(datafile,buf1,12,NumRead); //读用户名
BlockRead(datafile,buf2,12,NumRead); //读取密码
BlockRead(datafile,buf3,24,NumRead); //读权限
teL:=Length(buf2);
for ii:=1 to teL do //字符串加密
begin
teN:=NOT Ord(buf2[ii]);
buf2[ii]:=Chr(teN);
end;
if (s1=buf1)and(s2=buf2) then
begin
UserName:=s1;
UserPass:=s2;
if buf3[0]='^' then superPower:=True; //置权限
if buf3[1]='^' then userPower1:=True;
if buf3[2]='^' then userPower2:=True;
if buf3[3]='^' then userPower3:=True;
Result:=TRUE;
exit;
end;
until(NumRead=0);
closefile(datafile);
CmpPassword:=rt;
end;
在rt:=FALSE;
前加上
Result := False;
—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
rt:=FALSE;之前加句Result:=False;好像能解决第二个警告第一个不知警告不知怎解决?是不是你BlockRead用法有点问题
Exception EAccessViolation in module MDIAPP.exe at 00078ED3.
Access violaction at Address 00478ED3 in module 'MDIAPP.exe' .
Read of address 00A3AEF9.
2、函数的返回值可能没有定义,即在此函数执行完毕时,可能没有给Result给值,相当于它没有值,Result:=False; rt:=FALSE;