PRB: Property Not Evaluated When Object Is CreatedID: Q129424 3.00 WINDOWS
The information in this article applies to:
SYMPTOMSThe first time an instance of a class is created by using the CREATEOBJECT() function, the properties of the class hold correct values. However, if a property is based on an expression or a memory variable, it is not reevaluated when another object is instantiated. The properties are not redefined from the class definition once the class is in memory.
CAUSEThe property is evaluated in the body of the class definition. The class values are only evaluated the first time a class is loaded in memory. On the other hand, properties that are modified in a method of a class are evaluated each time the method is executed.
RESOLUTIONIf you want to evaluate a property based on an expression each time an object is created, place the expression in the Init method, which is executed each time the Init event takes place.
Sample CodeThe following sample code demonstrates this method. In this example, two properties are set. They evaluate the settings of SET TALK and SET EXACT. The first property is set in a class definition. It is evaluated the first time the class is loaded in memory. The value of the cSetExact property is set in the Init event handler for this class. It is evaluated every time an object is created.
STATUSThis behavior is by design. Additional reference words: 3.00 VFoxWin KBCategory: kbprb KBSubcategory: FxprgClassoop
|
Last Reviewed: May 22, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |