Problem walking the procedure tree

Posted by James Palmer on 05-Feb-2015 05:22

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]

All Replies

Posted by Mark Davies on 05-Feb-2015 06:34

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.

Posted by James Palmer on 05-Feb-2015 07:29

Thanks Mark I've managed to get this working satisfactorily now.

Posted by ornhill on 05-Feb-2015 13:25


On 05 Feb 2015, at 13:35, Mark Davies <bounce-markdprosoftitcoza@community.progress.com> wrote:

Reply by Mark Davies

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:      

This thread is closed