Browse Source

* Use StrToXXXDef functions for readXXX()

git-svn-id: trunk@7380 -
michael 18 years ago
parent
commit
fd096ef0f8
1 changed files with 8 additions and 40 deletions
  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);