Page 1 of 1

Event methods not deleted when controls deleted

Posted: Mon May 13, 2013 11:57 am
by davidmellow
Hi all

Something that I encountered a few times, that is not apparent until extracting a form and then attempting to load it into a different system...

The .scm file sometimes still contains definitions of event-handling methods relating to controls that have been deleted. For example tblSomename_click, when tblSomename has been removed from the form.

This causes the load to fail, and I have generally worked around this, rather crudely, by manually removing all references to the method from the .scm.

But just wondering, have others encountered this, it doesn't seem to be a consistent effect of removing a control?

Regards
Dvid

Re: Event methods not deleted when controls deleted

Posted: Mon May 13, 2013 12:09 pm
by BeeJay
Yes, I have seen this previously as well. To prevent the errors in future schema loads, you can access these methods in the source environment, from which you perform the schema extracts, and then remove them using the Methods Browser for the class in question. They won't show on the normal methods list in the CHB due to being "marked" as event methods.

Hope that helps,
BeeJay.

Re: Event methods not deleted when controls deleted

Posted: Mon May 13, 2013 2:50 pm
by davidmellow
Thanks BJ

Your advice about the methods browser gave me the info I needed to find them for deletion.

This script is a bit crude, in that as it stands it only looks up a schema hierarchy when run from a lower-most leaf schema, but I think (???) it lists all such rogue event handler methods (there were 4 in our system). If you can spot bugs in it let me know, but could be useful with a bit of modification - could be simpler ways but it seems to work.

Code: Select all

dsmFindBadFormEvents(); vars cls : Class; classCol : ClassColl; mSet : MethodSet; ty : Type; meth : Method; pos : Integer; form : Form; prop : Property; propName : String; cnt : Integer; begin cls := process.schema.getClass("Form"); create classCol transient; create mSet transient; cls.allSubclasses(classCol); foreach cls in classCol do cnt := 0; ty := cls; ty.allMethods(mSet); foreach meth in mSet do if meth.getPropertyValue("controlMethod") <> null then pos := meth.name.reversePos("_"); if pos > 1 then propName := meth.name[1 : pos - 1]; if cls.getPropertyInHTree(propName) = null then cnt.increment; if cnt = 1 then write ty.name; write "-----------------------------------------"; endif; write meth.name; endif; endif; endif; endforeach; mSet.clear; if cnt > 0 then write CrLf; endif; endforeach; epilog if classCol <> null then delete classCol; endif; if mSet <> null then delete mSet; endif; end;