function TryStrToBool(const S: string; out Value: Boolean): Boolean when in
it pass False in any time return false and it cause exception.
With best wishes, GSB.
> function TryStrToBool(const S: string; out Value: Boolean): Boolean when in
> it pass False in any time return false and it cause exception.
I don't get an exception; however, I can confirm that there is a bug in
the routine:
function TryStrToBool(const S: string; out Value: Boolean): Boolean;
// ...
var
LResult: Extended;
begin
Result := TryStrToFloat(S, LResult);
if Result then
Value := LResult <> 0
else
begin
// Result is currently false, because S wasn't a float
VerifyBoolStrArray;
if CompareWith(TrueBoolStrs) then
Value := True
else if CompareWith(FalseBoolStrs) then
Value := False
else
Result := False;
// Result still false
end;
end;
If the string isn't a valid float, it will always return false.
-- Barry
--
If you're not part of the solution, you're part of the precipitate.
Team JEDI: http://www.delphi-jedi.org
NNQ - Quoting Style in Newsgroup Postings
http://web.infoave.net/~dcalhoun/nnq/nquote.html
>In article <3b66422b_2@dnews>
> "Sergey Gusev" <g...@metacom.ru> wrote:
>
>> function TryStrToBool(const S: string; out Value: Boolean): Boolean when in
>> it pass False in any time return false and it cause exception.
>
>I don't get an exception;
You will get the exception when StrToBool is used (which runs into the
bug in TryStrToBool).
b := StrToBool('true');
raises EConvertError
which is a very annoying bug.
"Barry Kelly" <bar...@eircom.net> wrote in message
news:a7fdmtognd11088v3...@4ax.com...