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.
If I understand you correctly, I believe you need to look at SOURCR-PROCEDURE.
If I understand you correctly, I believe you need to look at SOURCR-PROCEDURE.
Thank you.
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.