Setting Component Properties to their defaults at runtime
|Date:||03 November 1999|
|Abstract:||Setting properties back to their default values at runtime|
|Submitted By:||LANSA Technical Support|
|Last Review:||November 2010|
When a component is dragged onto the form in the Component Editor, the component inherits a set of properties. Some of these properties have a default value of *NULL. This indicates that the property has not been set to any particular value and thus the default value for this property is to be used. If a property is changed from *NULL to another value and at runtime it changed back to its default again the property is not set back to *NULL. The value of the property is SET to be () (open bracket, close bracket). *NULL is an internal value and if used at runtime may cause inconsistent and unpredictable results.
Take a simple example. A pushbutton is dragged onto the form in the designer. The pushbutton inherits a property set. One of these properties is Image and it is set to *NULL (by default). The ellipse (...) for this property is clicked and a bitmap is selected to show on the pushbutton. The Image property changes to the field name of the bitmap. This form is compiled and executed and the bitmap displays on the pushbutton. However, at execution time the pushbutton is to be changed to have no image. If SET #PHBN_1 IMAGE(*NULL) is used, the image does not get set back to its default value because at execution time *NULL is not understood. Instead use SET #PHBN_1 IMAGE(), which will set the pushbutton to revert to its default value (of no image).
Note: Most properties can be changed back to their default value at execution time by setting the property to (), eg. SET #PHBN_1 Caption(), SET #LABL_1 Visible(), SET #TRVW_1 PopupMenu() etc. etc.