 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Per Dalgas Jakobsen Guest
|
Posted: Thu May 06, 2004 11:22 am Post subject: Default values for non-ordinal properties |
|
|
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 >
Best regards
Per
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu May 06, 2004 6:41 pm Post subject: Re: Default values for non-ordinal properties |
|
|
"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
|
Posted: Thu May 06, 2004 7:39 pm Post subject: Re: Default values for non-ordinal properties |
|
|
| 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 |
|
 |
|
|
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
|
|