The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,231 other followers

Delphi – finding published event handlers that have lost their binding from the DFM

Posted by jpluimers on 2018/05/15

The scripts in these links didn’t work well enough for me:

So I’ve been working on a GExperts based solution (because that gave me a nice starting point). It’s not fully done yet, so here are a few things I’ve used:

(Reminder to self: contact David Hoyle who knows a lot about the OTA).

–jeroen

# Be careful with scripts, always do your backup or play on a copy
# Finding abandoned events
for i in `find . -name "*.pas" -type f`; do if [ -f ${i%.*}.dfm ]; then cat $i | grep "(Sender: TObject" | grep -v "\." | sed -e "s/\(.*\)\ \(.*\)(\(.*\)/\2/g" | xargs -n1 -I @@ sh -c "echo -n \"${i%.*}.dfm->@@: \"; grep -s -c @@ ${i%.*}.dfm" |grep ": 0"; fi; done
# Finding events with every other occurence than "1"
for i in `find . -name "*.pas" -type f`; do if [ -f ${i%.*}.dfm ]; then cat $i | grep "(Sender: TObject" | grep -v "\." | sed -e "s/\(.*\)\ \(.*\)(\(.*\)/\2/g" | xargs -n1 -I @@ sh -c "echo -n \"${i%.*}.dfm->@@: \"; grep -s -c @@ ${i%.*}.dfm" |grep -v ": 1"; fi; done

# !!! Be careful with scripts, always do your backup or play on a copy !!!
# Finding abandoned events v2
for i in `find . -name "*.pas" -type f`; do if [ -f ${i%.*}.dfm ]; then cat $i | \
sed -nr "/=(\s)*class/I,/(private|protected|public|published|automated)/I{p}" | \
sed -nr "/procedure/Ip" | \
sed -e "s/\(.*\)\ \(.*\)(\(.*\)/\2/g" | \
xargs -n1 -I @@ sh -c "echo -n \"${i%.*}.dfm->@@: \"; grep -i -s -c @@ ${i%.*}.dfm" | \
grep ": 0"; fi; done

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: