` Printed Icetips Article

Icetips Article



Par2: Acting after UpdateProcedure
2005-02-22 -- Jim Gambon
 
> I want to perform some calcs when returning from an Insert, Change or
> Delete. I see embeds after parent call for each, but is there one embed I
> can use for all?

One of the secrets of successful OOP is to find the object method that most
specifically does the work that needs to be modified. In ABC all the Insert,
Update, and Delete actions eventually funnel through one method that is used
to call the actual UpdateForm. That method is prototyped like this:

 ThisWindow.Run PROCEDURE(USHORT Number,BYTE Request)

If your Windows has more than one Browse, and each has their own call to it's
own UpdateForm, then the "Number" parameter will be used to choose which
update form to call. The "Request" parameter will be a value that tells the
UpdateForm whether it is Inserting, Updating, etc.

In that method you will see code like this:

    GlobalRequest = Request
    UpdateForm
    ReturnValue = GlobalResponse

So, in priority 8500 or so you can put a Case statement to check the "Request"
(InsertRecord, ChangeRecord, DeleteRecord), and also whether the "response"
from the form was Completed or Cancelled.

Something like this:

IF GlobalResponse = RequestCompleted  ! Form Completed
  CASE Request
    OF InsertRecord
       ! Insert was successful
    OF ChangeRecord
       ! Change was successful
    OF DeleteRecord
       ! Delete was successful
  END !CASE
END !IF

Using embeds within the Run method means that you are attempting to modify the
behavior of how the UpdateForm is called, however it is called. It gets the
logic of your code closer to the call of the UpdateForm, and makes sure that
it fires only when the form is called.

Note: there are two Run methods. The one without any parameters is the one
that Run's the Window. That is not the one you want.



Printed April 28, 2024, 10:00 pm
This article has been viewed/printed 35114 times.