*--An interesting glitch in BindEvents. PUBLIC oform1 oform1=NEWOBJECT("form1") oform1.Show RETURN DEFINE CLASS form1 AS form Top = 0 Left = 0 Height = 220 Width = 300 LastValue = "" Caption = "BindEvent Test" ADD OBJECT Container1 AS container WITH ; TOP = 20, ; LEFT = 80, ; HEIGHT = 60, ; WIDTH = 120, ; NAME = 'Container1' ADD OBJECT Command1 AS commandbutton WITH ; TOP = 120, ; LEFT = 20, ; HEIGHT = 27, ; WIDTH = 95, ; NAME = 'Command1', ; CAPTION = "Blank" ADD OBJECT command2 AS commandbutton WITH ; AutoSize = .T., ; Top = 120, ; Left = 160, ; Height = 27, ; Width = 95, ; Name = "Command2" CAPTION = "Container" PROCEDURE Init *--Fire the event handler after the value has changed. BINDEVENT(this, "LastValue", This, "DisplayLastValueType", 1) ENDPROC PROCEDURE command1.Click *--Blank out the form property. thisform.LastValue = "" *** ****Q: Why would the bound event sometimes fire twice after this value change? ****A: When the variable / form property changes from containing a ****an object reference to a character value, VFP first reassigns the value ****to .NULL. then assigns the new value. **** ENDPROC PROCEDURE command2.Click *--Store an object reference pointing to the container to the form property. thisform.LastValue = ThisForm.Container1 ENDPROC PROCEDURE DisplayLastValueType IF VARTYPE(ThisForm.LastValue) = "O" WAIT WINDOW TIMEOUT 2 "LastValue: Changed to Object Reference " + TRANSFORM(SECONDS()) ELSE WAIT WINDOW TIMEOUT 2 "LastValue: Changed to blank " + NVL(ThisForm.lastValue," [Value is NULL!!!]") + " " + TRANSFORM(SECONDS()) ENDIF ENDDEFINE