CLEAR ON ERROR cc=CREATEOBJECT("testCollection") ? "COUNT is",cc.Count ? ? "next add a Item with a BEFORE BINDEVENT" ? "Never errors, but Item return .T. !!!" ? "cc.Item(1) return",cc.Item(1) ? " retry return",cc.Item(1) DEFINE CLASS testCollection As Collection PROCEDURE Init BINDEVENT(m.This,"item",m.This,"BindItem") PROCEDURE BindItem(eIndex) UNBINDEVENT(m.This,"item",m.This,"BindItem") this.Add("Item One") RETURN && !!!!!!!!!!!! COMMENT THIS, AND FIRST RETURN 1 RETURN .T. ENDPROC PROCEDURE Error LPARAMETERS nError, cMethod, nLine ? nError, cMethod, nLine,PROGRAM(),ERROR(),MESSAGE(),LINENO(),SYS(2018) ENDDEFINEOn help is written:
CLEAR ON ERROR ? MESSAGE() cc=CREATEOBJECT("testCollection") ? "COUNT is",cc.Count ? ? "next add a Item with a BEFORE BINDEVENT" ? "Fire error, or return 1 !!!" ? "cc(1) return",cc(1) ? " retry return",cc(1) DEFINE CLASS testCollection As Collection PROCEDURE Init BINDEVENT(m.This,"item",m.This,"BindItem") PROCEDURE BindItem(eIndex) ? PROGRAM() UNBINDEVENT(m.This,"item",m.This,"BindItem") this.Add("Item One") RETURN && !!!!!!!!!!!! COMMENT THIS, AND FIRST RETURN 1 RETURN .T. ENDPROC PROCEDURE Error LPARAMETERS nError, cMethod, nLine ? nError, cMethod, nLine,PROGRAM(),ERROR(),MESSAGE(),LINENO(),SYS(2018) ENDDEFINEUPDATE: without the bindevent
CLEAR ON ERROR cc=CREATEOBJECT("testCollection") ? "cc(1) return",cc.Item(1) DEFINE CLASS testCollection As Collection * WORKAROUND: uncomment next two lines ( but this slow down the process ) * PROCEDURE item(eIndex) * RETURN collection::Item(eIndex) PROCEDURE Error LPARAMETERS nError, cMethod, nLine ? " the Class's Error catch the error, and add the Item" THIS.Add("ItemToAdd") ? " but the retry is ignored" ? RETRY ENDDEFINE