SUPER-PROCEDURE

Posted by ecsousa on 25-Aug-2016 14:52

Hi,

When I am executing a procedure, how can I find the This-Procedure Handle from the source code that called this current procedure?


for example:  inside proc1, how can i know if it was called by font2 or fontN??  I tried to use program-name(2)  but I don´t want the name of the source code, I want the handle.

main.p:

procedure proc1:

message "Called by:   ???? " .

end procedure.

font1.p :
Define Variable hMain As Handle No-undo.

Run main.p Persistent Set hMain No-error.

If Valid-handle(hMain) Then
    session:Add-super-procedure(hMain).


font2: 
message "Font2 handle:  " this-procedure.
run proc1().
.
.
.
fontN: 
message "FontN handle:  " this-procedure.
run proc1().


Thank you,

PS: Sorry about my writing mistakes, English is not my mother language.

Posted by Mike Fechner on 25-Aug-2016 15:01

Check the SOURCE-PROCEDURE and TARGET-PROCEDURE handle.

The target procedure is the procedure on who's behalf a super procedure is executed. The source procedure is the caller.





Posted by Simon L. Prinsloo on 25-Aug-2016 15:00

If I understand you correctly, I believe you need to look at SOURCR-PROCEDURE.

All Replies

Posted by Simon L. Prinsloo on 25-Aug-2016 15:00

If I understand you correctly, I believe you need to look at SOURCR-PROCEDURE.

Posted by Mike Fechner on 25-Aug-2016 15:01

Check the SOURCE-PROCEDURE and TARGET-PROCEDURE handle.

The target procedure is the procedure on who's behalf a super procedure is executed. The source procedure is the caller.





Posted by ecsousa on 25-Aug-2016 15:15

Thank you.

Posted by smat-consulting on 25-Aug-2016 16:18

getting the procedure handle reliably is a bit of a pain. Not sure what you re trying to do, but here's the include-file I use in ally procedures to link the required super-procedures like this:

     { sys/inc/startSuper.i }

     RUN start-super-proc("xyz/abc/p").

     RUN start-super-proc("xyz/efg.p").

If the procedure is already in memory (i.e. started persistently by another .p) I simply use the handle of the running procedure. If it is not yet running, I start it, and use that handle.

I don't see how I can attach a file to this message, so I placed it for you here:

 www.smat-consulting.com/.../startSuper.i

Note: if you include - for testing purposes - the following statement right after the RUN start-super-proc statements, it'll display all the super-procedures of this particular .p with their handles.

     RUN displaySuperProcedures

Sorry about the men commented out code-segments. This file has grown over the last almost 20 years - and I encountered several "undocumented features" in various versions, and had to find a way to identify and work around them.

This thread is closed