PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Error handler Object handling.  (Read 431 times)

Peter.Higgins

  • Gold Member
  • ****
  • Posts: 91
    • View Profile
Error handler Object handling.
« on: January 14, 2021, 02:53:54 PM »
Looking to add an object manager to programs and the error handler so it can drop them.

At first I thought *master might work, but not in *nix from the results I get. 

I also was thinking there was a newish object manager utility to keep object references in, but all I can find that is useful is the *obj/collection.pvc which leaves a lot of coding to implement everywhere else.

Am I missing one somewhere?

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3462
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: Error handler Object handling.
« Reply #1 on: January 14, 2021, 08:22:20 PM »
Not certain exactly what you are looking for but have you considered just using the FOR clause on the NEW function when creating objects?

For Example:

myObj = NEW("object_name" FOR PROGRAM) ! Will drop object when program exits/end
myObj = NEW("object_name" FOR WINDOW) ! Will drop object when window closed
myObj = NEW("object_name" FOR FILE nnn) ! Will drop object when file nnn closed
myObj = NEW("object_name" FOR OBJECT nnn) ! Will drop object when secondary object nnn is dropped


Saves a lot of work remembering when to drop objects.

Peter.Higgins

  • Gold Member
  • ****
  • Posts: 91
    • View Profile
Re: Error handler Object handling.
« Reply #2 on: January 15, 2021, 11:57:00 AM »
Thanks Mike,

Cannot believe something this important has been around for 15+ years and I am just now learning it even after taking 3 dedicated months to learn what I missed after going down the Sage & Infor fork rabbit holes.

"For Windows" is perfect for regular nomads programs.
 
"For Program" says "the current program level is exited." Does this mean the object only persists while on one level, or through higher level calls/methods?

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3462
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: Error handler Object handling.
« Reply #3 on: January 16, 2021, 08:49:59 PM »
The FOR PROGRAM lasts until the current program level (CALL, PERFORM, etc...) exits.  The Object does remain through lower levels so if the current level itself issues a CALL, PERFORM or executes a method call, the object will remain.  Basically the object remains until the current level issues an EXIT or END (or RETURN to a higher level - -not a GOSUB return)
 

Peter.Higgins

  • Gold Member
  • ****
  • Posts: 91
    • View Profile
Re: Error handler Object handling.
« Reply #4 on: May 14, 2021, 12:08:21 PM »
Mike,
How does For Program work for a Run, such as Run Menu?

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3462
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: Error handler Object handling.
« Reply #5 on: May 14, 2021, 12:18:13 PM »
The FOR PROGRAM option ties the object to the current program level. 

That is if you are in a called program and instantiate an object with a FOR PROGRAM then when your called program exits the object will automatically be de-referenced/dropped.

If you use the FOR PROGRAM on the top level program the object will be dereferenced when the program ends.