|
|||||
|
The Following Tips and Tricks are Available :
If you have any Tips and Tricks yourself, please mail them to : matd@oocities.com
Bugs in Setting Default values for properties
I don't know wether I did something wrong or not but the 'default' reserved word doesn't do a thing when I use it in my components , what's more, when I try to set the property to it's default value in design time, it completely ignores that value at run-time, causing errors that are completely unexpected and, ofcoarse hard to trace. Lets see an example of this :
If you experience trouble like this, you should stop using the 'default' reserved word and use the constructor to set set your property values. Like this:
Ever had a stack-error ? You know, these errors that show these nice win95 error boxes and force you to shut down Delphi without first saving your work. If you were unlucky you probably had to shut down windows or even your computer ( this is, if you work with windows 95, I suppose that NT doesn't give that much troubles ).
These errors are most commonly caused by a never ending loop. What do you say ? You aren't so stupid that you cause a neverending loop ? Possible, but you forget that a neverending loop is also what you get if you've got a function that calls itself and, for that matter, functions that call themselfs include property set procedures. The following will cause such an error :
The line that causes the error is :
SomeThing:=V;
Because this try's to set the property, which runs the setSomething property. That way this is a selfcalling function but a camouflaged one. What should be there instead is:
valSomeThing:=V;