BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Default values for non-ordinal properties

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
Per Dalgas Jakobsen
Guest





PostPosted: Thu May 06, 2004 11:22 am    Post subject: Default values for non-ordinal properties Reply with quote



Hi all,

Is there a way to get the IDE to accept different default values for
published properties, or to make it store, non-ordinal values for all
values?

Problem:
I have a property of type double, which I want to have a default value
different from zero. No problem, I just set the value in the constructor of
the class.
IF however, the user for some reason finds out that the default value is not
suitable for him/her, and sets it to zero, he/she will get the default value
(not zero).

Reason:
BCB seems to assume a default value, of whatever gives the binary
representation of zeros, and will not store values which are the default
anyway In many cases that will be ok, but not always for strings, doubles
and other non-ordinal types. And since default and nodefault keywords are
not supported for non-ordinal types, it seems like you cannot "convince" the
IDE to use another default, or store the values into the *.dfm-files in any
case. (The compiler actually accepts the nodefault keyword for doubles, but
it has, as expected, no effect).

Solution:
<please fill in here Wink>

Best regards
Per


Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu May 06, 2004 6:41 pm    Post subject: Re: Default values for non-ordinal properties Reply with quote




"Per Dalgas Jakobsen" <i (AT) hate (DOT) spam> wrote


Quote:
I have a property of type double, which I want to have a default
value different from zero. No problem, I just set the value in the
constructor of the class.

Did you give the property declaration itself a "default" clause as well?

Quote:
BCB seems to assume a default value, of whatever gives the
binary representation of zeros, and will not store values which
are the default anyway

That is why you have to give your property declaration a "default" clause
that specifies what the actual default value really is.

Quote:
it seems like you cannot "convince" the IDE to use another
default, or store the values into the *.dfm-files in any case.

You will probably have to stream the value manually then. Look at
overrideing the DefineProperties() method.


Gambit



Back to top
Per Dalgas Jakobsen
Guest





PostPosted: Thu May 06, 2004 7:39 pm    Post subject: Re: Default values for non-ordinal properties Reply with quote



Quote:
I have a property of type double, which I want to have a default
value different from zero. No problem, I just set the value in the
constructor of the class.

Did you give the property declaration itself a "default" clause as well?

According to the documentation (and I even believe I tried it to be sure),
"default" is not supported for non-ordinal types... (Strangely enough,
"nodefault" is... - Go figure).


Quote:
BCB seems to assume a default value, of whatever gives the
binary representation of zeros, and will not store values which
are the default anyway

That is why you have to give your property declaration a "default" clause
that specifies what the actual default value really is.

Yes.


Quote:
it seems like you cannot "convince" the IDE to use another
default, or store the values into the *.dfm-files in any case.

You will probably have to stream the value manually then. Look at
overrideing the DefineProperties() method.

That would complicate component-writing for certain components quite a bit
(without proper reason I would say). I can't believe Borland have made such
a bummer, there *must* be a "right" way to do this!?!
I would find it useable if "nodefault" really meant, no default, at least
for the types not covered by the "default" specifier.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.