Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL    [ Add a report in this area ]  
Report #:  928   Status: Need Feedback
Int64 properties of components not saved if value is 0
Project:  Delphi Build #:
Version:    6.0 Submitted By:   Lasse Karlsen
Report Type:  Basic functionality failure Date Reported:  4/20/2002 7:38:54 AM
Severity:    Commonly encountered problem Last Updated: 1/19/2010 12:34:10 AM
Platform:    All platforms Internal Tracking #:  
Resolution: Need More Info (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (16 Total Ratings)
3.88 out of 5
Total Votes: None
Any component with an Int64 property will not have the value of that property saved, if the value is 0.

nodefault, default -10, stored True, neither of those will make sure the property is saved. The only solution is setting the default value of the property to 0 as well, something that might not be suitable in all instances.
Steps to Reproduce:
Basic component that shows off problem:

  TInt64Component = class(TComponent)
    FValue: Int64;
    constructor Create(AOwner: TComponent); override;
    property Value: Int64 read FValue write FValue default -10;

constructor TInt64Component.Create(AOwner: TComponent);
  FValue := -10;

install this, and try setting the value to 0, notice that if you close and reopen form, the value is back to -10.

Ray Lischner at 4/20/2002 8:09:48 AM -
The real problem is that the compiler does not issue a warning when the user incorrectly tries to assign a default value to properties of type Int64, string, floating point, etc.

Default property values are supported only for ordinal and set-type published properties.

Lasse Karlsen at 5/6/2002 11:25:46 PM -
As long as it's impossible to set a default value for the Int64 properties, making sure "Stored X" works, or that it's saved regardless should not be that hard to make.

For instance, I have a range component (the case I had the problem with) that has two Int64 properties for Min and Max range. These two defaults to the lowest and highest value possible. The bug I had problems with though was that in one case I wanted to set the instance range from 0 to 100, but 0 was never saved, hence the minimum was always the lowest Int64 value possible.

The alternatives for me included setting the default value of the property to 0 (but the minimum value I had chosen practically meant "no minimum value") or replace with Integer. I went for the second in this case but I'd rather have it fixed so that Int64 can be useful as a property.

Colin Wilson at 4/23/2002 2:57:44 AM -
> Default property values are supported only for ordinal and set-type published properties.

The Delphi documentation isn't clear on whether it considers Int64 to be an ordinal type.  For instance if you look up 'ordinal types' it says "Ordinal types include integer, character, Boolean, enumerated, and subrange types." - but if you look up 'Succ' it says "X is an expression of an ordinal type (including Int64)."

Logically though, int64 is an ordinal type,

Ray Lischner at 4/23/2002 9:12:52 AM -
In that case, the defect is that the compiler does not warn the user when the user tries to specify a default property for a type that is not a 32-bit ordinal or set. The documentation should also be improved.

Jouni Aro at 10/17/2008 3:47:04 AM -
The same problem is valid for float properties. You cannot even use a 'stored' specifier to change the behavior: 0 is never stored, so that is the only valid default value for all float properties!  I guess, I will create a new QC for that.

Tomohiro Takahashi at 10/17/2008 4:40:18 AM -
>  I guess, I will create a new QC for that.
Yes please.

Server Response from: ETNACODE01