There's probably a really simple answer to this problem but I'm struggling to find it.
I have some code in our application that walks the procedure tree (session:first-procedure) and reports back various bits of info on the procedures so we can track down runtime issues. It works really well, except for when you have various windows that call each other. It only shows the first window.
The code uses myHandle:NEXT-SIBLING to traverse. I've tried using FIRST-CHILD but get a message saying that's an invalid property for procedure handles. So how can I find the children?
I've attached some code that shows the issue. If you run 1.w and then hit the button in 3.w it only reports 1.w in the output.
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/7536.1.w:550:0][View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/7450.2.w:550:0][View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/3.w:550:0]
Hi,
You need to get the first child, this gives you the window handle and then get the window's instantiating procedure to walk the procedure tree.
Replace the button code with this:
RUN GetProcedures IN THIS-PROCEDURE
(INPUT SESSION:FIRST-CHILD)
and then use the following code in your GetProcedures procedure:
PROCEDURE GetProcedures :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DEFINE INPUT PARAMETER ip-Handle AS HANDLE NO-UNDO.
DEFINE VARIABLE lvInst AS HANDLE NO-UNDO.
DEFINE VARIABLE hProc AS HANDLE NO-UNDO.
IF VALID-HANDLE(ip-Handle) THEN
DO:
IF ip-handle:TYPE = "WINDOW" AND VALID-HANDLE(ip-handle:INSTANTIATING-PROCEDURE) THEN
hProc = ip-handle:INSTANTIATING-PROCEDURE.
ELSE
hProc = ip-handle.
IF CAN-QUERY(hProc,"INSTANTIATING-PROCEDURE") AND
VALID-HANDLE(hProc:INSTANTIATING-PROCEDURE) THEN
DO:
CREATE ttProcedures.
ASSIGN
lvInst = hProc:INSTANTIATING-PROCEDURE.
ASSIGN
ttProcedures.ProcHandle = hProc
ttProcedures.ProcName = hProc:NAME
ttProcedures.ProcInstantiator = lvInst:NAME
WHEN VALID-HANDLE(lvInst)
ttProcedures.ProcFileName = hProc:FILENAME
ttProcedures.ProcPersistent = hProc:PERSISTENT
ttProcedures.SuperProc = LOOKUP(STRING(hProc),SESSION:SUPER-PROCEDURES) GT 0.
END.
RUN GetProcedures(ip-Handle:NEXT-SIBLING).
END.
END PROCEDURE.
Thanks Mark I've managed to get this working satisfactorily now.
Reply by Mark DaviesHi,
You need to get the first child, this gives you the window handle and then get the window's instantiating procedure to walk the procedure tree.
Replace the button code with this:
RUN GetProcedures IN THIS-PROCEDURE
(INPUT SESSION:FIRST-CHILD)
and then use the following code in your GetProcedures procedure:
PROCEDURE GetProcedures :
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes: