Event methods not deleted when controls deleted

For questions and postings not covered by the other forums
davidmellow
Posts: 42
Joined: Thu Aug 27, 2009 1:27 pm
Location: New Plymouth, New Zealand

Event methods not deleted when controls deleted

Postby davidmellow » Mon May 13, 2013 11:57 am

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

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: Event methods not deleted when controls deleted

Postby BeeJay » Mon May 13, 2013 12:09 pm

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.

davidmellow
Posts: 42
Joined: Thu Aug 27, 2009 1:27 pm
Location: New Plymouth, New Zealand

Re: Event methods not deleted when controls deleted

Postby davidmellow » Mon May 13, 2013 2:50 pm

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;


Return to “General Discussion”

Who is online

Users browsing this forum: Bing [Bot] and 42 guests