Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Build my own BINDEVENT for AfterInsert
Message
From
28/07/2013 05:00:50
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
27/07/2013 09:21:19
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01578580
Message ID:
01579314
Views:
98
Now I see that you already had some help from Thomas, who said what I did, just much better.

The trouble of your situation is that you don't know whether the main app's code uses a cursoradapter or not. You can make this work only if it doesn't - if you attach your cursoradapter to a cursor, any other adapter on the same cursor would get detached (and from that point on I don't really remember what happens to it - once I had a situation I fixed it immediately). Any code written in that adapter would not fire - yours would - so you have a chance of breaking their code.

So, here's an idea. Try to see if there's an adapter (a GETCURSORADAPTER(lcAlias)). If it exists, bindevent() to it; if it doesn't, create your own and attach it to the cursor. The adapter events will fire on each tableupdate() on that alias.
try
   loAdapter=GETCURSORADAPTER(lcAlias)
catch to loErr
   loAdapter=createobject("cursoradapter")
   loAdapter.CursorAttach(lcAlias, .t.)
endtry

bindevent(loAdapter, "AfterInsert", myObject, "myMethod")
You'd need more error checking (alias not used, buffering doesn't support having an adapter on the cursor), and you'd need to make sure the adapter stays in scope. Debugging will then be nasty, if you can't run a copy of the app you're hooking into within VFP.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform