The scope of CREATEOBJECT
2007-01Jan-13
Sometimes one gains insights that are absolutely useless. One such piece is the scope of CREATEOBJECT(). The first time you instantiate an object from a class, Visual FoxPro creates a template object with all the properties values that the class defines. If the class definition contains an expression for one of the properties, Visual FoxPro evaluates it at this time once. For any further instance, Visual FoxPro uses the pre-evaluated expression from the class object.
Local lcVar, loRef
lcVar = "Hi"
loRef = CreateObject("Test")
? loRef.cTest
Define Class Test as Custom
cTest = m.lcVar
EndDefine