Sorry for the quick assumption :-)
Yes it work, I have edited your code a little to better see the order of events.
It does not loop because its called before actually changing the value of the property
The side effect of this is that you cannot use the binded event as a prop_assign() replacement...
PRIVATE o, x
o = NEWOBJECT('Empty')
ADDPROPERTY(o, 'FireInit')
x = NEWOBJECT('EmptyMethods')
BINDEVENT(o, 'FireInit', x, 'FireInit')
CLEAR
WAIT WINDOW 'FireInit value - ' + TRANSFORM(o.FireInit)
o.FireInit = 5
WAIT WINDOW 'FireInit value - ' + TRANSFORM(o.FireInit)
o.FireInit = 10
WAIT WINDOW 'FireInit value - ' + TRANSFORM(o.FireInit)
DEFINE CLASS EmptyMethods AS Custom
PROCEDURE FireInit
WAIT WINDOW 'FireInit fired a - ' + TRANSFORM(o.FireInit)
IF TYPE('o.FireInit') = "N"
o.FireInit = o.FireInit + 1
ELSE
o.FireInit = 1
ENDIF
WAIT WINDOW 'FireInit fired b - ' + TRANSFORM(o.FireInit)
ENDPROC
PROCEDURE Release
RELEASE THIS
ENDPROC
ENDDEFINE
>>So this does not work as expected!
>>Change your code to assign 5 to the o.FireInit instead of .t.
>>
>>The bindevent fire, but you notice that its not a numeric value...
>>
>>My conclusion is that the event fire only on the assignment "BINDEVENT(o, 'FireInit', x, 'FireInit')"
>>and not on subsequent changes of the property value.
>>
>>Comments?
>
>The part about it not going into an endless loop indeed did surprise me. However, I will not count on this behaviour as the potential for future releases of VFP might "fix" this. This may, however, be the actual design behaviour by the VFP Team. Of that, I am not sure. I am glad that the current behaviour prevents such a disaster.
>
>As long as you are setting the property outside the method, the method will fire every time. The following does fire the method all 3 times
>PRIVATE o, x
>o = NEWOBJECT('Empty')
>ADDPROPERTY(o, 'FireInit')
>x = NEWOBJECT('EmptyMethods')
>BINDEVENT(o, 'FireInit', x, 'FireInit')
>CLEAR
>o.FireInit = 1
>o.FireInit = 2
>o.FireInit = 3
>
>
>DEFINE CLASS EmptyMethods AS Custom
>
> PROCEDURE FireInit
>*!* IF TYPE('o.FireInit') = "N"
>*!* o.FireInit = o.FireInit + 1
>*!* ELSE
>*!* o.FireInit = 1
>*!* ENDIF
> WAIT WINDOW 'FireInit fired - ' + TRANSFORM(o.FireInit)
> ENDPROC
> PROCEDURE Release
> RELEASE THIS
> ENDPROC
>
>ENDDEFINE
>
If we exchange an apple, we both get an apple.
But if we exchange an idea, we both get 2 ideas, cool...Gérald Santerre
Independant programmer - internet or intranet stuff - always looking for contracts big or small :)
http://www.siteintranet.qc.ca