Browse Source

+ Added some missing functions needed for variant support

michael 25 years ago
parent
commit
385a257995
3 changed files with 84 additions and 12 deletions
  1. 15 9
      rtl/objpas/stre.inc
  2. 52 1
      rtl/objpas/sysstr.inc
  3. 17 2
      rtl/objpas/sysstrh.inc

+ 15 - 9
rtl/objpas/stre.inc

@@ -23,6 +23,7 @@ Const
 
 
    { Error messages for exceptions }
    { Error messages for exceptions }
    
    
+   SAbortError = 'Operation aborted';
    SAbstractError = 'Abstract method called';
    SAbstractError = 'Abstract method called';
    SAccessDenied = 'Access denied';
    SAccessDenied = 'Access denied';
    SAccessViolation = 'Access violation';
    SAccessViolation = 'Access violation';
@@ -32,34 +33,39 @@ Const
    SDiskFull = 'Disk Full';
    SDiskFull = 'Disk Full';
    SDivByZero = 'Division by zero';
    SDivByZero = 'Division by zero';
    SEndOfFile = 'Read past end of file';
    SEndOfFile = 'Read past end of file';
-   SFileNotFound = 'File not found';
+   SExceptionErrorMessage = 'exception at %p';
    SFileNotAssigned = 'File not assigned';
    SFileNotAssigned = 'File not assigned';
+   SFileNotFound = 'File not found';
    SFileNotOpen = 'File not open';
    SFileNotOpen = 'File not open';
    SFileNotOpenForInput = 'File not open for input';
    SFileNotOpenForInput = 'File not open for input';
    SFileNotOpenForOutput = 'File not open for output';
    SFileNotOpenForOutput = 'File not open for output';
+   SInValidFileName = 'Invalid filename';
+   SIntOverflow = 'Arithmetic overflow';
    SInvalidArgIndex = 'Invalid argument index in format "%s"';
    SInvalidArgIndex = 'Invalid argument index in format "%s"';
+   SInvalidBoolean = '"%s" is not a valid boolean.';
+   SInvalidCast = 'Invalid type cast';
+   SInvalidDateTime = '%f is not a valid datee/time value.';
    SInvalidDrive = 'Invalid drive specified';
    SInvalidDrive = 'Invalid drive specified';
    SInvalidFileHandle = 'Invalid file handle';
    SInvalidFileHandle = 'Invalid file handle';
-   SInValidFileName = 'Invalid filename';
    SInvalidFloat = '"%s" is an invalid float';
    SInvalidFloat = '"%s" is an invalid float';
    SInvalidFormat = 'Invalid format specifier : "%s"';
    SInvalidFormat = 'Invalid format specifier : "%s"';
    SInvalidInput = 'Invalid input';
    SInvalidInput = 'Invalid input';
    SInvalidInteger = '"%s" is an invalid integer';
    SInvalidInteger = '"%s" is an invalid integer';
+   SInvalidOp = 'Invalid floating point operation';
    SInvalidPointer = 'Invalid pointer operation';
    SInvalidPointer = 'Invalid pointer operation';
    SOutOfMemory = 'Out of memory';
    SOutOfMemory = 'Out of memory';
+   SOverflow = 'Floating point overflow';
    SRangeError = 'Range check error';
    SRangeError = 'Range check error';
-   SInvalidCast = 'Invalid type cast';
    STooManyOpenFiles = 'Too many open files';
    STooManyOpenFiles = 'Too many open files';
    SUnKnownRunTimeError = 'Unknown Run-Time error : %3.3d';
    SUnKnownRunTimeError = 'Unknown Run-Time error : %3.3d';
-   SOverflow = 'Floating point overflow';
    SUnderflow = 'Floating point underflow';
    SUnderflow = 'Floating point underflow';
-   SIntOverflow = 'Arithmetic overflow';
-   SInvalidOp = 'Invalid floating point operation';
-   SAbortError = 'Operation aborted';
-   SExceptionErrorMessage = 'exception at %p';
+     
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2000-07-13 11:33:51  michael
+  Revision 1.3  2000-08-13 17:55:38  michael
+  + Added some missing functions needed for variant support
+
+  Revision 1.2  2000/07/13 11:33:51  michael
   + removed logs
   + removed logs
  
  
 }
 }

+ 52 - 1
rtl/objpas/sysstr.inc

@@ -1125,6 +1125,54 @@ Begin
   End;
   End;
 End;
 End;
 
 
+Function FloatToDateTime (Const Value : Extended) : TDateTime;
+begin
+  If (Value<MinDateTime) or (Value>MaxDateTime) then
+    Raise EConvertError.CreateFmt (SInvalidDateTime,[Value]);
+  Result:=Value;
+end; 
+
+Function FloatToCurr (Const Value : Extended) : Currency;
+begin
+    
+end; 
+
+Function CurrToStr(Value: Currency): string;
+begin
+end; 
+
+function StrToCurr(const S: string): Currency;
+begin
+end; 
+
+function StrToBool(const S: string): Boolean;
+
+Var 
+  Temp : String;
+  D : Double;
+  Code : word;
+
+begin
+  Temp:=upcase(S);
+  Val(temp,D,code);
+  If Code=0 then
+    Result:=(D<>0.0)
+  else If Temp='TRUE' then
+    result:=true
+  else if Temp='FALSE' then
+    result:=false
+  else
+    Raise EConvertError.CreateFmt(SInvalidBoolean,[S]);
+end; 
+
+function BoolToStr(B: Boolean): string;
+begin
+  If B then
+    Result:='TRUE'
+  else
+    Result:='FALSE'; 
+end;
+
 {==============================================================================}
 {==============================================================================}
 {   extra functions                                                            }
 {   extra functions                                                            }
 {==============================================================================}
 {==============================================================================}
@@ -1217,7 +1265,10 @@ const
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2000-08-09 07:48:05  marco
+  Revision 1.4  2000-08-13 17:55:38  michael
+  + Added some missing functions needed for variant support
+
+  Revision 1.3  2000/08/09 07:48:05  marco
    * Uncommented some int64 functions, now that int64 support is ok
    * Uncommented some int64 functions, now that int64 support is ok
 
 
   Revision 1.2  2000/07/13 11:33:51  michael
   Revision 1.2  2000/07/13 11:33:51  michael

+ 17 - 2
rtl/objpas/sysstrh.inc

@@ -30,8 +30,12 @@ type
    
    
    { For FloatToText } 
    { For FloatToText } 
    TFloatFormat = (ffGeneral, ffExponent, ffFixed, ffNumber, ffCurrency);
    TFloatFormat = (ffGeneral, ffExponent, ffFixed, ffNumber, ffCurrency);
-
    
    
+const
+  { For floattodatetime }
+  MinDateTime: TDateTime = -657434.0;      { 01/01/0100 12:00:00.000 AM }
+  MaxDateTime: TDateTime =  2958465.99999; { 12/31/9999 11:59:59.999 PM }
+       
 function NewStr(const S: string): PString;
 function NewStr(const S: string): PString;
 procedure DisposeStr(S: PString);
 procedure DisposeStr(S: PString);
 procedure AssignStr(var P: PString; const S: string);
 procedure AssignStr(var P: PString; const S: string);
@@ -84,6 +88,14 @@ Function FloatToStr(Value: Extended): String;
 Function StrToFloat(Value : String) : Extended;
 Function StrToFloat(Value : String) : Extended;
 Function FloatToText(Buffer: PChar; Value: Extended; format: TFloatFormat; Precision, Digits: Integer): Longint;
 Function FloatToText(Buffer: PChar; Value: Extended; format: TFloatFormat; Precision, Digits: Integer): Longint;
 
 
+Function FloatToDateTime (Const Value : Extended) : TDateTime;
+Function FloattoCurr (Const Value : Extended) : Currency;
+Function CurrToStr(Value: Currency): string;
+function StrToCurr(const S: string): Currency;
+function StrToBool(const S: string): Boolean;
+function BoolToStr(B: Boolean): string;
+
+
 {==============================================================================}
 {==============================================================================}
 {   extra functions                                                            }
 {   extra functions                                                            }
 {==============================================================================}
 {==============================================================================}
@@ -94,7 +106,10 @@ function BCDToInt(Value: integer): integer;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2000-08-09 07:48:05  marco
+  Revision 1.4  2000-08-13 17:55:38  michael
+  + Added some missing functions needed for variant support
+
+  Revision 1.3  2000/08/09 07:48:05  marco
    * Uncommented some int64 functions, now that int64 support is ok
    * Uncommented some int64 functions, now that int64 support is ok
 
 
   Revision 1.2  2000/07/13 11:33:51  michael
   Revision 1.2  2000/07/13 11:33:51  michael