Jump to content


Photo

TNxCustomNumberEdit returns random value if NullText is used ...


  • Please log in to reply
8 replies to this topic

#1 rond

rond
  • Members
  • 50 posts
  • Location:Lieshout, The Netherlands

Posted 11 February 2011 - 12:03 PM

I have a NextDbGrid with a database integer field that can be empty.
However I noticed that whenever the user entered an 'empty' text the I got an exception telling me that the value (which appeared to be a random floatingpoint value like 3E-20 ) was not a valid integer.

Checking the code I saw this :
CODE

function TNxCustomNumberEdit.GetValue: Double;
var
ValidText: string;
begin
if (Text = NullText) then
begin
Value := 0;
Exit;
end;
if Text = '' then Result := FMin else
begin
ValidText := GetValidText(Text, eoAllowFloat in FOptions, eoAllowSigns in FOptions);
if ValidText = '' then ValidText := FloatToStr(Min);
if TryStrToFloat(ValidText, Result) then
begin
AdjustToRange(Result);
FValue := Result;
end else Result := FValue;
end;

I'm guessing that because there is no Return-value for the function the 'random' value is returned whenever 'eoAllowFloat' is enabled, because doing so 'fixes' this but stops the user from entering empty values.


#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 11 February 2011 - 06:26 PM

Hello,

Can you tell me what did you set for EmptyText.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 rond

rond
  • Members
  • 50 posts
  • Location:Lieshout, The Netherlands

Posted 11 February 2011 - 06:30 PM

QUOTE (Boki (Berg) @ Feb 11 2011, 06:26 PM) <{POST_SNAPBACK}>
Hello,

Can you tell me what did you set for EmptyText.

Best regards

I think I had EmptyText to the default value which is an empty IIRC.

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 11 February 2011 - 06:58 PM

Hello,

Maybe a small demo project may help?

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#5 rond

rond
  • Members
  • 50 posts
  • Location:Lieshout, The Netherlands

Posted 14 February 2011 - 10:36 AM

QUOTE (Boki (Berg) @ Feb 11 2011, 06:58 PM) <{POST_SNAPBACK}>
Hello,

Maybe a small demo project may help?

Best regards

I will see what I can do.

The one important bit that I can think of are regional settings affecting the conversion.
I'm using a Dutch operating system and my regional/language settings are Dutch as well.
This means that floating point values are displayed with a comma "," instead of a decimal point "."
So I'm thinking that might be a possible cause.

// -- edit --
I've tried the exact same code on a different pc and it's fine.
This is really really strange.
I did find that on that other pc the return-value from the routine is '0'.

#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 15 February 2011 - 12:33 AM

Hello Rond,

Maybe regional setting on different PC is not same as on your PC.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#7 rond

rond
  • Members
  • 50 posts
  • Location:Lieshout, The Netherlands

Posted 15 February 2011 - 12:11 PM

QUOTE (Boki (Berg) @ Feb 15 2011, 12:33 AM) <{POST_SNAPBACK}>
Hello Rond,

Maybe regional setting on different PC is not same as on your PC.

Best regards

that would be a huge problem, because I can't exactly ask our customers to change their regional settings.

Besides ... the return-value in the method is undefined (it calls 'exit' without setting the return value!), which makes any results unpredictable.

-- edit --
I checked the settings and both computers where using the same OS and regional settings.


#8 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 16 February 2011 - 12:25 AM

Hello Rond,

Small demo project will really help. I am having non-english regional settings and maybe I will notice bug imidiately. But I must note that while developing component I didn't use any fixed settings and that I have take care about this things.

Thank you
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#9 rond

rond
  • Members
  • 50 posts
  • Location:Lieshout, The Netherlands

Posted 16 February 2011 - 10:29 AM

The issue appears to have gone away and as I said the same code didn't cause a problem on a different pc. sad.gif
I did change these settings :
- NextDbGrid now has 'buffered records' set to true
- the number-columns have precision and formattext properties set

As a result I don't know what exactly caused this issue and what I need to do in a demo-project to cause this problem to re-appear.
You might get some results with the one I posted in this topic : http://www.bergsoft....h...&hl=sorting




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users