Browse Source

* booltostr now D7 compat.

git-svn-id: trunk@5744 -
marco 18 years ago
parent
commit
4264f5d041
2 changed files with 30 additions and 6 deletions
  1. 26 5
      rtl/objpas/sysutils/sysstr.inc
  2. 4 1
      rtl/objpas/sysutils/sysstrh.inc

+ 26 - 5
rtl/objpas/sysutils/sysstr.inc

@@ -1373,23 +1373,44 @@ begin
     Raise EConvertError.CreateFmt(SInvalidBoolean,[S]);
     Raise EConvertError.CreateFmt(SInvalidBoolean,[S]);
 end;
 end;
 
 
+function BoolToStr(B: Boolean;UseBoolStrs:Boolean=False): string;
 
 
-function BoolToStr(B: Boolean): string;
+procedure CheckStrs;
 begin
 begin
+    If Length(TrueBoolStrs)=0 then
+      begin
+        SetLength(TrueBoolStrs,1);
+        TrueBoolStrs[0]:='True';
+      end;
+    If Length(FalseBoolStrs)=0 then
+      begin
+        SetLength(FalseBoolStrs,1);
+        FalseBoolStrs[0]:='False';
+      end;
+end;
+
+begin
+ if UseBoolStrs Then
+  begin
+    CheckStrs;
+    if B then
+      Result:=TrueBoolStrs[0] 
+    else
+      Result:=FalseBoolStrs[0];
+  end
+ else
   If B then
   If B then
-    Result:='TRUE'
+    Result:='-1'
   else
   else
-    Result:='FALSE';
+    Result:='0';
 end;
 end;
 
 
-
 function StrToBoolDef(const S: string; Default: Boolean): Boolean;
 function StrToBoolDef(const S: string; Default: Boolean): Boolean;
 begin
 begin
   if not(TryStrToBool(S,Result)) then
   if not(TryStrToBool(S,Result)) then
     Result:=Default;
     Result:=Default;
 end;
 end;
   
   
-  
 function TryStrToBool(const S: string; out Value: Boolean): Boolean;
 function TryStrToBool(const S: string; out Value: Boolean): Boolean;
 Var
 Var
   Temp : String;
   Temp : String;

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

@@ -59,6 +59,9 @@ Const
   EmptyWideStr : WideString = '';
   EmptyWideStr : WideString = '';
 //  NullWideStr : PWideString = @EmptyWideStr;
 //  NullWideStr : PWideString = @EmptyWideStr;
 
 
+Var TrueBoolStrs,
+    FalseBoolStrs : Array of String;
+
 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);
@@ -161,7 +164,7 @@ function TryStrToCurr(const S: string;Var Value : Currency): Boolean;
 function StrToCurrDef(const S: string; Default : Currency): Currency;
 function StrToCurrDef(const S: string; Default : Currency): Currency;
 
 
 function StrToBool(const S: string): Boolean;
 function StrToBool(const S: string): Boolean;
-function BoolToStr(B: Boolean): string;
+function BoolToStr(B: Boolean;UseBoolStrs:Boolean=False): string;
 function StrToBoolDef(const S: string; Default: Boolean): Boolean;
 function StrToBoolDef(const S: string; Default: Boolean): Boolean;
 function TryStrToBool(const S: string; out Value: Boolean): Boolean;
 function TryStrToBool(const S: string; out Value: Boolean): Boolean;