how to know handle of .p that NEWd an object

Posted by joey eisma on 15-Jan-2016 12:56

hi!

initially i thought INSTANTIATING-PROCEDURE was my friend. but it's not supported by objects.

so how to know the .p that NEW'd an object?

thanks!

joey

All Replies

Posted by Peter Judge on 15-Jan-2016 13:00

Why do you want to know that?
 
You can always pass a value into the constructor if it's important.
 

Posted by Tim Kuehn on 15-Jan-2016 13:01

Why do you want to do that? That's usually a smell test. If that information is really required for an object, then pass the instantiating procedure's handle through the constructor. Better yet, pass the context information instead, leave the procedure handle out of it, and you'll have functionality that's usable anywhere, and not restricted to a single context.

Posted by joey eisma on 15-Jan-2016 13:26

from the object i needed to run a procedure in the instantiating .p. i don't want to pass the handle to the constructor cause in some cases, i may not be calling the procedure.

i moved the procedure into a session super. which works fine for now. but was hoping to be more explicit though by passing RUN xx IN <PROC-HANDLE>.  walking the procedure handle chains will get me the handle also.

so, i guess there is no ready made to get to the handle of the procedure? i have to bake one myself.

thanks though.

Posted by Tim Kuehn on 15-Jan-2016 13:29

[quote user="joey eisma"] from the object i needed to run a procedure in the instantiating .p. i don't want to pass the handle to the constructor cause in some cases, i may not be calling the procedure. [/quote]

Then make two constructors - like so:

CONSTRUCTOR MyClass(hHandle AS HANDLE):
   /* Stuff */
END CONSTRUCTOR.


CONSTRUCTOR MyClass():
   /* Stuff */
END CONSTRUCTOR.

Posted by joey eisma on 15-Jan-2016 13:35

thanks tim. but..

RUN xx IN <PROC-HANDLE> will not run in the constructor. it's one of the methods that **may** not be called. i don't want to define a handle variable that **may** not be used as well.

This thread is closed