Browse Source

+ Patch from Colin Western to implemenet TryStrToFLoat

michael 20 years ago
parent
commit
95714e9a4e
2 changed files with 26 additions and 2 deletions
  1. 19 1
      rtl/objpas/sysutils/sysstr.inc
  2. 7 1
      rtl/objpas/sysutils/sysstrh.inc

+ 19 - 1
rtl/objpas/sysutils/sysstr.inc

@@ -1236,6 +1236,21 @@ Begin
   Result:=(E=0);
 End;
 
+Function TryStrToFloat(Const S : String; Var Value: Single): Boolean;
+Begin
+  Result := TextToFloat(PChar(S), Value, fvSingle);
+End;
+
+Function TryStrToFloat(Const S : String; Var Value: Double): Boolean;
+Begin
+  Result := TextToFloat(PChar(S), Value, fvDouble);
+End;
+
+Function TryStrToFloat(Const S : String; Var Value: Extended): Boolean;
+Begin
+  Result := TextToFloat(PChar(S), Value);
+End;
+
 Function FloatToStr(Value: Extended): String;
 Begin
   Result := FloatToStrF(Value, ffGeneral, 15, 0);
@@ -2320,7 +2335,10 @@ const
 
 {
   $Log$
-  Revision 1.24  2004-12-26 13:04:30  peter
+  Revision 1.25  2005-01-16 17:53:27  michael
+  + Patch from Colin Western to implemenet TryStrToFLoat
+
+  Revision 1.24  2004/12/26 13:04:30  peter
     * fix bugs 3477, 3478, 3479
 
   Revision 1.23  2004/12/19 17:55:38  michael

+ 7 - 1
rtl/objpas/sysutils/sysstrh.inc

@@ -139,6 +139,9 @@ Function FloatToStrF(Value: Extended; format: TFloatFormat; Precision, Digits: I
 Function FloatToStr(Value: Extended): String;
 Function StrToFloat(Const S : String) : Extended;
 Function StrToFloatDef(Const S: String; Const Default: Extended): Extended;
+Function TryStrToFloat(Const S : String; Var Value: Single): Boolean;
+Function TryStrToFloat(Const S : String; Var Value: Double): Boolean;
+Function TryStrToFloat(Const S : String; Var Value: Extended): Boolean;
 Function TextToFloat(Buffer: PChar; Var Value: Extended): Boolean;
 Function TextToFloat(Buffer: PChar; Var Value; ValueType: TFloatValue): Boolean;
 Function FloatToText(Buffer: PChar; Value: Extended; format: TFloatFormat; Precision, Digits: Integer): Longint;
@@ -195,7 +198,10 @@ function BCDToInt(Value: integer): integer;
 
 {
   $Log$
-  Revision 1.11  2004-12-19 17:55:38  michael
+  Revision 1.12  2005-01-16 17:53:27  michael
+  + Patch from Colin Western to implemenet TryStrToFLoat
+
+  Revision 1.11  2004/12/19 17:55:38  michael
   + Implemented wraptext
 
   Revision 1.10  2004/11/16 18:30:36  marco