Subject Re: order of events
From Ken Mayer <dbase@nospam.goldenstag.net>
Date Fri, 18 Sep 2020 21:52:54 -0700
Newsgroups dbase.getting-started

On 9/18/2020 5:57 PM, Gaetano wrote:
>
> Hi All,
>
> I was trying to use the beforeConnect event for an ADO query and it
> fired before the canOpen event. While I do know the basics about the
> order for canEvents, beforeEvent and onEvents for a same event type, I
> don't know how they relate to some other events like in this case
> beforeConnect.

I am guessing that "beforeConnect" would have to do with the database
object, not the query ... this event handler doesn't appear in help for
the ado objects (although I know that the help for ADO isn't as
up-to-date as it should be). I would check that, first.

However, think it through. *IF* this is a real event handler,
beforeConnect would logically have to fire before you could open the
query, because you would have to connect to the database first. Then you
could attempt a canOpen to open the query itself. Does that make sense?


>
> I guess that my underlying question is whether there is always a
> built-in order for each and every event to be fired for a given object
> or do some events fire according to the order they appear in the code?
> and if there is a hard-coded order, is there somewhere that I can look
> up theĀ  order for a given object?

canEvents fire before the method. So if you have, for example:

canSave() // returns true/false, if false, save() doesn't fire,
           // and therefore onSave() doesn't fire
Save()    // fires if a) no canSave event handler is defined, or
           // if b) a canSave event handler returns true.
onSave()  // only fires after the save method fires, see above.

"before" is not a normal event handler in dBASE, so I can't speak to it
... but I would think it would fire either before the canEvent, as noted
above. I do little with ADO (did some testing for my books, but don't
use it normally).

Ken

--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm