Atributos ou propriedades do Handle

Discussão em 'Progress 4GL' iniciado por cristofergirardi, Março 25, 2013.

  1. cristofergirardi

    cristofergirardi Sem Pontuação

    Boa tarde,

    Estou criando um "debugador" de BOs para analisar performance e o que é criado na memória da máquina durante a execução.

    Os primeiros passos consegui fazer que seria: saber quais os programas que estão sendo executados ou que estão persistentes em memória. (FÁCIL). Bom agora vem os problemas, quero saber quais são as procedures ou functions que estão sendo executados ou abertos pelos programas. É possível? Ou existe algum documento que me diga quais são os atributos ou propriedades do handle que consiga ler?

    Att.
    Cristofer Girardi.
  2. cristofergirardi

    cristofergirardi Sem Pontuação

    Bom dia a todos,

    Depois de algumas pesquisas encontrei um pouco mais de informação mas não é tudo o que eu realmente gostaria. Segue abaixo o código para conhecimento de todos.

    Se alguém quiser colaborar com este fonte, por favor, fiquem a vontade.


    &Scoped-define WINDOW-NAME C-Win

    CREATE WIDGET-POOL.

    &Scoped-define PROCEDURE-TYPE Window
    &Scoped-define DB-AWARE no

    /* Name of designated FRAME-NAME and/or first browse and/or first query */
    &Scoped-define FRAME-NAME DEFAULT-FRAME

    /* Variable definitions */
    DEFINE TEMP-TABLE tt-handles NO-UNDO
    FIELD h-handle AS INTEGER
    FIELD c-file-name AS CHARACTER FORMAT "X(30)"
    FIELD c-procedure-name AS CHARACTER FORMAT "X(40)"
    FIELD c-transaction AS LOGICAL FORMAT "Sim/Nao"
    FIELD c-instantiating AS CHARACTER FORMAT "X(40)"
    FIELD h-handle-called AS INTEGER.

    DEFINE VARIABLE method-return AS LOGICAL NO-UNDO.
    DEFINE VARIABLE hProcedure AS HANDLE NO-UNDO.
    DEFINE QUERY q1 FOR tt-handles SCROLLING.
    DEFINE BROWSE b1 QUERY q1 NO-LOCK
    DISPLAY /*tt-handles.c-file-name COLUMN-LABEL "Arquivos"*/
    tt-handles.h-handle-called COLUMN-LABEL "Handle executor"
    tt-handles.c-instantiating COLUMN-LABEL "Executor"
    tt-handles.h-handle COLUMN-LABEL "Handle"
    tt-handles.c-procedure-name COLUMN-LABEL "Procedure"
    tt-handles.c-transaction COLUMN-LABEL "Transacao em Aberto?"
    ENABLE tt-handles.h-handle-called
    tt-handles.c-instantiating
    tt-handles.h-handle
    tt-handles.c-procedure-name
    tt-handles.c-transaction
    WITH 15 DOWN WIDTH 126 MULTIPLE NO-ASSIGN SEPARATORS.
    DEFINE BUTTON button1 LABEL "Atualizar".

    /* *********************** Control Definitions ********************** */
    /* Define the widget handle for the window */
    DEFINE VAR C-Win AS WIDGET-HANDLE NO-UNDO.

    /* ************************ Frame Definitions *********************** */
    DEFINE FRAME DEFAULT-FRAME
    b1 SKIP(1)
    button1
    WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
    NO-UNDERLINE THREE-D AT COL 1 ROW 1 SIZE 126 BY 17 WIDGET-ID 100.

    ASSIGN tt-handles.h-handle:AUTO-RESIZE IN BROWSE b1 = TRUE
    tt-handles.h-handle:COLUMN-READ-ONLY IN BROWSE b1 = TRUE
    /*tt-handles.c-file-name:AUTO-RESIZE IN BROWSE b1 = TRUE
    tt-handles.c-file-name:COLUMN-READ-ONLY IN BROWSE b1 = TRUE*/
    tt-handles.c-procedure-name:AUTO-RESIZE IN BROWSE b1 = TRUE
    tt-handles.c-procedure-name:COLUMN-READ-ONLY IN BROWSE b1 = TRUE
    tt-handles.c-transaction:AUTO-RESIZE IN BROWSE b1 = TRUE
    tt-handles.c-transaction:COLUMN-READ-ONLY IN BROWSE b1 = TRUE
    tt-handles.h-handle-called:AUTO-RESIZE IN BROWSE b1 = TRUE
    tt-handles.h-handle-called:COLUMN-READ-ONLY IN BROWSE b1 = TRUE
    tt-handles.c-instantiating:AUTO-RESIZE IN BROWSE b1 = TRUE
    tt-handles.c-instantiating:COLUMN-READ-ONLY IN BROWSE b1 = TRUE
    b1:COLUMN-RESIZABLE IN FRAME DEFAULT-FRAME = TRUE.

    /* ************************* Create Window ************************** */

    IF SESSION:DISPLAY-TYPE = "GUI":U THEN
    CREATE WINDOW C-Win ASSIGN
    HIDDEN = YES
    TITLE = "Procedures que estao em aberto"
    HEIGHT = 17
    WIDTH = 126
    MAX-HEIGHT = 17
    MAX-WIDTH = 126
    VIRTUAL-HEIGHT = 17
    VIRTUAL-WIDTH = 126
    RESIZE = yes
    SCROLL-BARS = no
    STATUS-AREA = no
    BGCOLOR = ?
    FGCOLOR = ?
    KEEP-FRAME-Z-ORDER = yes
    THREE-D = yes
    MESSAGE-AREA = no
    SENSITIVE = yes.
    ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
    /* END WINDOW DEFINITION */


    /* *********** Runtime Attributes *********** */

    /* SETTINGS FOR WINDOW C-Win
    VISIBLE,,RUN-PERSISTENT */
    /* SETTINGS FOR FRAME DEFAULT-FRAME
    FRAME-NAME */
    IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(C-Win)
    THEN C-Win:HIDDEN = no.

    /* Set CURRENT-WINDOW: this will parent dialog-boxes and frames. */
    ASSIGN CURRENT-WINDOW = {&WINDOW-NAME}
    THIS-PROCEDURE:CURRENT-WINDOW = {&WINDOW-NAME}.

    /* The CLOSE event can be used from inside or outside the procedure to */
    /* terminate it. */
    ON CLOSE OF THIS-PROCEDURE
    RUN disable_UI.

    /* Best default for GUI applications is... */
    PAUSE 0 BEFORE-HIDE.

    ON 'CHOOSE':U OF button1 IN FRAME DEFAULT-FRAME DO:
    RUN re-create-query.
    END.

    ON 'F5':U OF b1 IN FRAME DEFAULT-FRAME
    DO:
    RUN re-create-query.
    END.

    /* Now enable the interface and wait for the exit condition. */
    /* (NOTE: handle ERROR and END-KEY so cleanup code will always fire. */
    MAIN-BLOCK:
    DO ON ERROR UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
    ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
    RUN enable_UI.
    IF NOT THIS-PROCEDURE:pERSISTENT THEN
    WAIT-FOR CLOSE OF THIS-PROCEDURE.
    END.


    /* ********************** Internal Procedures *********************** */

    PROCEDURE disable_UI :
    /*------------------------------------------------------------------------------
    Purpose: DISABLE the User Interface
    Parameters: <none>
    Notes: Here we clean-up the user-interface by deleting
    dynamic widgets we have created and/or hide
    frames. This procedure is usually called when
    we are ready to "clean-up" after running.
    ------------------------------------------------------------------------------*/
    /* Delete the WINDOW we created */
    IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(C-Win)
    THEN DELETE WIDGET C-Win.
    IF THIS-PROCEDURE:pERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
    END PROCEDURE.

    PROCEDURE enable_UI :
    /*------------------------------------------------------------------------------
    Purpose: ENABLE the User Interface
    Parameters: <none>
    Notes: Here we display/view/enable the widgets in the
    user-interface. In addition, OPEN all queries
    associated with each FRAME and BROWSE.
    These statements here are based on the "Other
    Settings" section of the widget Property Sheets.
    ------------------------------------------------------------------------------*/

    RUN create-query.
    ENABLE ALL WITH FRAME DEFAULT-FRAME IN WINDOW C-Win.
    END PROCEDURE.

    PROCEDURE create-query:
    hProcedure = SESSION:FIRST-PROCEDURE.
    DO WHILE VALID-HANDLE(hProcedure):
    CREATE tt-handles.
    ASSIGN tt-handles.h-handle = hProcedure:HANDLE AS INTEGER
    tt-handles.c-file-name = hProcedure:FILE-NAME
    tt-handles.c-procedure-name = hProcedure:NAME
    tt-handles.c-transaction = hProcedure:TRANSACTION:IS-OPEN
    tt-handles.h-handle-called = hProcedure:INSTANTIATING-PROCEDURE AS INTEGER
    tt-handles.c-instantiating = IF hProcedure:INSTANTIATING-PROCEDURE <> ? THEN hProcedure:INSTANTIATING-PROCEDURE:NAME ELSE "".

    hProcedure = hProcedure:NEXT-SIBLING.
    END.
    OPEN QUERY q1 FOR EACH tt-handles INDEXED-REPOSITION.

    END PROCEDURE.

    PROCEDURE re-create-query:
    FOR EACH tt-handles EXCLUSIVE-LOCK:
    DELETE tt-handles.
    END.
    hProcedure = SESSION:FIRST-PROCEDURE.
    DO WHILE VALID-HANDLE(hProcedure):
    CREATE tt-handles.
    ASSIGN tt-handles.h-handle = hProcedure:HANDLE AS INTEGER
    tt-handles.c-file-name = hProcedure:FILE-NAME
    tt-handles.c-procedure-name = hProcedure:NAME
    tt-handles.c-transaction = hProcedure:TRANSACTION:IS-OPEN
    tt-handles.h-handle-called = hProcedure:INSTANTIATING-PROCEDURE AS INTEGER
    tt-handles.c-instantiating = IF hProcedure:INSTANTIATING-PROCEDURE <> ? THEN hProcedure:INSTANTIATING-PROCEDURE:NAME ELSE "".

    hProcedure = hProcedure:NEXT-SIBLING.
    END.
    CLOSE QUERY q1.
    OPEN QUERY q1 FOR EACH tt-handles INDEXED-REPOSITION.


    END PROCEDURE.
    afarns e marcelom curtiram isso.

Compartilhe esta Página