function TConfig.Readbool(ConfigID:EnConfig): boolean;
var
MyIniFile: TIniFile;
tBool:boolean;
MainKey: string;
SubKey: string;
begin
tBool := false;
MainKey := 'MainUI';
if FileExists(FCfgFile) = false then Result := false;
case ConfigID of
swToolBar: SubKey := 'ShowToolBar';
swState: SubKey := 'ShowState';
swQueryResult: SubKey := 'ShowQueryResult';
swLoginForm:
begin
MainKey := 'LOAD';
SubKey := 'ShowLoginForm';
end;
end;
MyIniFile := TIniFile.Create(FCfgFile);
tBool := MyIniFile.ReadBool(MainKey,SubKey,false);
MyIniFile.Free;
Result := tBool;
end;function TMyApp.Login: boolean;
var
loginForm:TLoginForm;
tBool: boolean;
begin
tBool := FConfig.Readbool(swLoginForm);
if tBool = false then
begin
Result := true; //为什么这一句总不会运行?????
end;
loginForm := TLoginForm.Create(FMainForm);
Application.CreateForm(TLoginForm, loginForm);
tBool := loginForm.Login;
loginForm.Free;
Result := tBool;
end;我都疯了,怎么那么怪啊,返回值就是false,但为什么下面begin里面的就不执行呢?晕倒
var
MyIniFile: TIniFile;
tBool:boolean;
MainKey: string;
SubKey: string;
begin
tBool := false;
MainKey := 'MainUI';
if FileExists(FCfgFile) = false then Result := false;
case ConfigID of
swToolBar: SubKey := 'ShowToolBar';
swState: SubKey := 'ShowState';
swQueryResult: SubKey := 'ShowQueryResult';
swLoginForm:
begin
MainKey := 'LOAD';
SubKey := 'ShowLoginForm';
end;
end;
MyIniFile := TIniFile.Create(FCfgFile);
tBool := MyIniFile.ReadBool(MainKey,SubKey,false);
MyIniFile.Free;
Result := tBool;
end;function TMyApp.Login: boolean;
var
loginForm:TLoginForm;
tBool: boolean;
begin
tBool := FConfig.Readbool(swLoginForm);
if tBool = false then
begin
Result := true; //为什么这一句总不会运行?????
end;
loginForm := TLoginForm.Create(FMainForm);
Application.CreateForm(TLoginForm, loginForm);
tBool := loginForm.Login;
loginForm.Free;
Result := tBool;
end;我都疯了,怎么那么怪啊,返回值就是false,但为什么下面begin里面的就不执行呢?晕倒
我也很菜~~~~~~
还有FCfgFile是什么?变量?里面的值是什么! 提点意见,仅供参考!
if tBool = false then
begin
Result := true; //为什么这一句总不会运行?????
end;为什么在调试设断点的时候 Result := true; 这一句前面是个"叉",怪啊,不管里面语句执不执行都应该是个"勾"的啊?
比如: if tBool = false then
begin
Result := true;
ShowMessage(True);
end;
if tBool = false then <执行>
begin
. <不执行>
. <不执行>
. <不执行>
end
else
begin
. <不执行>
. <不执行>
end;
... <执行>
if tBool = false then <执行>
begin
这两句,我有一次不小心在写代码时输入了中文全角方式的空格也出现过问题,后来好不容易才想到。
仅供参考!!
你把 Project->Options->Compiler->Optimization 打勾去掉 ,再单步看看也就是说系统认为您的TBRESULT没用,