浏览代码

* Use StrToXXXDef functions for readXXX()

git-svn-id: trunk@7380 -
michael 18 年之前
父节点
当前提交
fd096ef0f8
共有 1 个文件被更改,包括 8 次插入40 次删除
  1. 8 40
      packages/fcl-base/src/inc/inifiles.pp

+ 8 - 40
packages/fcl-base/src/inc/inifiles.pp

@@ -387,59 +387,27 @@ begin
 end;
 
 function TCustomIniFile.ReadDate(const Section, Ident: string; Default: TDateTime): TDateTime;
-var
-  s: string;
+
 begin
-  Result := Default;
-  s := ReadString(Section, Ident, '');
-  if s > '' then try
-    Result := StrToDate(s);
-  except
-    on EConvertError do
-    else raise;
-  end;
+  Result := StrToDateDef(ReadString(Section, Ident, ''),Default);
 end;
 
 function TCustomIniFile.ReadDateTime(const Section, Ident: string; Default: TDateTime): TDateTime;
-var
-  s: string;
+
 begin
-  Result := Default;
-  s := ReadString(Section, Ident, '');
-  if s > '' then try
-    Result := StrToDateTime(s);
-  except
-    on EConvertError do
-    else raise;
-  end;
+  Result := StrToDateTimeDef(ReadString(Section, Ident, ''),Default);
 end;
 
 function TCustomIniFile.ReadFloat(const Section, Ident: string; Default: Double): Double;
-var
-  s: string;
+
 begin
-  Result := Default;
-  s := ReadString(Section, Ident, '');
-  if s > '' then try
-    Result := StrToFloat(s);
-  except
-    on EConvertError do
-    else raise;
-  end;
+  Result:=StrToFloatDef(ReadString(Section, Ident, ''),Default);
 end;
 
 function TCustomIniFile.ReadTime(const Section, Ident: string; Default: TDateTime): TDateTime;
-var
-  s: string;
+
 begin
-  Result := Default;
-  s := ReadString(Section, Ident, '');
-  if s > '' then try
-    Result := StrToTime(s);
-  except
-    on EConvertError do
-    else raise;
-  end;
+  Result := StrToTimeDef(ReadString(Section, Ident, ''),Default);
 end;
 
 procedure TCustomIniFile.WriteDate(const Section, Ident: string; Value: TDateTime);