NetTalk Central

Author Topic: Pre Routines  (Read 3156 times)

Gordon Holfelder

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
    • Email
Pre Routines
« on: October 04, 2010, 02:36:33 PM »
Hi All-

Back to working on my NT5 app and have run into a problem. I have a table bowse calling a memory form (I have different tables I want to update) and need to catch insert vs change vs delete. I've set debugger break points in the PreInsert, PreUpdate and PreDelete routines and the only one I'm getting to is the PreUpdate

Is this because it's a memory form or am I missing something?

Is there a GSV or GV that will tell me what button was pressed?

Thanks,
Gordon

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Pre Routines
« Reply #1 on: October 04, 2010, 05:01:30 PM »
Is this because it's a memory form or am I missing something?

> yes. change is the std behaviour

Is there a GSV or GV that will tell me what button was pressed?

> there is a GV on a normal form although you would need to check your logging window to see if this is different on a memory form. If it is you could just create your own ins, chg and del buttons and pass whatever values you like to the memory form.

Gordon Holfelder

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
    • Email
Re: Pre Routines
« Reply #2 on: October 05, 2010, 10:11:41 AM »
Hello Kevin-

RE: My own buttons: I like the messaging, etc. that is associated with the standard buttons. I'd like to not have to do this for every browse where I have to use this technique.

I have found the following code in the PreUpdate routine lets me determine if this is a insert or change:
IF p_web.GetValue('insert_btn') <> ''
  DO PreInsertStuff
ELSIF p_web.GetValue('change_btn') <> ''
  DO PreChangeStuff
ELSE
  Not sure why we would be here
END

Interesting that on an insert it get's here once and on a change twice. For a delete though, the only way to trap it is in the InitFormEnd embed point:
IF BAND(p_Stage, 255) = Net:DeleteRecord
  DO PostDeleteStuff
END

The only problem is that it goes through here twice with no difference that I can tell (I've looked at p_stage and it doesn't change). Any ideas how I can make the delete happen once?

Thanks,
Gordon

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Pre Routines
« Reply #3 on: October 05, 2010, 11:12:49 AM »
On the first pass set a value
p_web.SetValue('BeenHereDoneThis',1)

Then wrap your init code in a test for the value

If p_web.GetValue('BeenHereDoneThis') = 0

Cheers
Bruce

Gordon Holfelder

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
    • Email
Re: Pre Routines
« Reply #4 on: October 05, 2010, 12:21:15 PM »
Hello Bruce-

Thanks. That did the trick.

See you soon,
Gordon