Quellcode durchsuchen

Implemented strtofloat

michael vor 26 Jahren
Ursprung
Commit
aae9265b5c
3 geänderte Dateien mit 25 neuen und 3 gelöschten Zeilen
  1. 5 1
      rtl/objpas/stre.inc
  2. 15 1
      rtl/objpas/sysstr.inc
  3. 5 1
      rtl/objpas/sysstrh.inc

+ 5 - 1
rtl/objpas/stre.inc

@@ -40,6 +40,7 @@ Const
    SInvalidDrive = 'Invalid drive specified';
    SInvalidFileHandle = 'Invalid file handle';
    SInValidFileName = 'Invalid filename';
+   SInvalidFloat = '"%s" is an invalid float';
    SInvalidFormat = 'Invalid format specifier : "%s"';
    SInvalidInput = 'Invalid input';
    SInvalidInteger = '"%s" is an invalid integer';
@@ -51,7 +52,10 @@ Const
    SUnKnownRunTimeError = 'Unknown Run-Time error : %3.3d';
 {
   $Log$
-  Revision 1.5  1998-10-10 09:53:09  michael
+  Revision 1.6  1999-06-19 07:39:46  michael
+  Implemented strtofloat
+
+  Revision 1.5  1998/10/10 09:53:09  michael
   Added assertion handling
 
   Revision 1.4  1998/10/03 15:08:04  florian

+ 15 - 1
rtl/objpas/sysstr.inc

@@ -880,6 +880,17 @@ begin
   Result:=Buffer;
 end;
 
+
+function StrToFloat(Value: string): Extended;
+
+var Error: word;
+
+begin
+  Val(Value, result, Error);
+  if Error <> 0 then raise 
+     EConvertError.createfmt(SInValidFLoat,[Value]);
+end ;
+
 Function FloatToStr(Value: Extended): String;
 Begin
   Result := FloatToStrF(Value, ffGeneral, 15, 0);
@@ -1130,7 +1141,10 @@ const
 
 {
   $Log$
-  Revision 1.21  1999-06-05 20:47:03  michael
+  Revision 1.22  1999-06-19 07:39:44  michael
+  Implemented strtofloat
+
+  Revision 1.21  1999/06/05 20:47:03  michael
   + Final fixes: RightStr
 
   Revision 1.20  1999/05/31 20:50:45  peter

+ 5 - 1
rtl/objpas/sysstrh.inc

@@ -80,6 +80,7 @@ Function StrLFmt(Buffer : PCHar; Maxlen : Cardinal;Fmt : PChar; Const args: Arra
 Procedure FmtStr(Var Res: String; Const Fmt : String; Const args: Array of const);
 Function FloatToStrF(Value: Extended; format: TFloatFormat; Precision, Digits: Integer): String;
 Function FloatToStr(Value: Extended): String;
+Function StrToFloat(Value : String) : Extended;
 Function FloatToText(Buffer: PChar; Value: Extended; format: TFloatFormat; Precision, Digits: Integer): Longint;
 
 {==============================================================================}
@@ -92,7 +93,10 @@ function BCDToInt(Value: integer): integer;
 
 {
   $Log$
-  Revision 1.7  1999-05-28 20:08:21  michael
+  Revision 1.8  1999-06-19 07:39:43  michael
+  Implemented strtofloat
+
+  Revision 1.7  1999/05/28 20:08:21  michael
   * too may fixes to list
 
   Revision 1.6  1999/02/28 13:17:36  michael