DEFINE CLASS myclass As Custom HIDDEN lInternalAssigment hwindow=0 PROCEDURE Init THIS.GetHWindow() PROCEDURE hwindow_ASSIGN(newvalue) IF This.lInternalAssigment THIS.hwindow = newvalue ELSE ERROR 1740, "HWindow" ENDIF PROCEDURE hwindow_ACCESS RETURN THIS.hwindow PROTECTED PROCEDURE GetHWindow DECLARE INTEGER GetFocus IN user32 This.lInternalAssigment = .T. THIS.hwindow=GetFocus() This.lInternalAssigment = .F. ENDDEFINE>In FoxPro class I want to create read-only property. Its value can be changed by internal method(s) of the class, but can not be changed by direct assignment when an object is instantiated from this class.
>obj = CreateObject("myclass") >? obj.hwindow >* obj.hwindow=0 && generates an error >* end of main > >DEFINE CLASS myclass As Custom >PROTECTED _hwindow > hwindow=0 > >PROCEDURE Init > THIS.GetHWindow > >PROCEDURE hwindow_ASSIGN(newvalue) > ERROR 1740, "HWindow" > >PROCEDURE hwindow_ACCESS >RETURN THIS._hwindow > >PROTECTED PROCEDURE GetHWindow > DECLARE INTEGER GetFocus IN user32 > THIS._hwindow=GetFocus() > >ENDDEFINE >>Is there a better way? Somehow this triple-member does not look Ok.