jaisonantoniazzi

Listar Campos de Browser através de Handle 2014-01-20

upc,buffer,query,handle

  1. jaisonantoniazzi
    /* para este programa funcionar, basta atribuir handle de um browser para a variavel hbrowser */
    DEFINE NEW GLOBAL SHARED VARIABLE hBrowser AS HANDLE NO-UNDO.

    DEFINE VARIABLE hquery AS HANDLE NO-UNDO.
    DEFINE VARIABLE hbuffer AS HANDLE NO-UNDO.
    DEFINE VARIABLE contar AS INTEGER NO-UNDO.
    DEFINE STREAM stCampos.
    DEFINE VARIABLE arquivo AS CHARACTER NO-UNDO.

    /* se o handle nao for valido, cai fora */
    IF NOT VALID-HANDLE(hBrowser) THEN
    RETURN.

    /* capturar a query do browser */
    hquery = hBrowser:QUERY.
    /* capturar o buffer da query */
    hbuffer = hquery:GET-BUFFER-HANDLE(1).

    /* nome do arquivo */
    arquivo = SESSION:TEMP-DIR + 'listarcampos.txt'.

    OUTPUT STREAM stCampos TO VALUE( arquivo ) CONVERT TARGET 'ISO8859-1'.

    /* primeiro registro da query */
    hquery:GET-FIRST().
    DO WHILE hbuffer:AVAIL:

    /* listar todos os campos do buffer */
    REPEAT contar = 1 TO hbuffer:NUM-FIELDS:

    EXPORT STREAM stCampos
    hbuffer:BUFFER-FIELD(contar):NAME
    hbuffer:BUFFER-FIELD(contar):DATA-TYPE
    hbuffer:BUFFER-FIELD(contar):FORMAT
    hbuffer:BUFFER-FIELD(contar):BUFFER-VALUE .

    END.

    /* pular uma linha a cada registro exportado */
    PUT STREAM stCampos SKIP(1).

    /* proximo registro da query */
    hquery:GET-NEXT().
    END.

    OUTPUT STREAM stCampos CLOSE.

    /* pegar os erros */
    CATCH erro AS PROGRESS.Lang.SysError:
    MESSAGE "Ocorreu erro inesperado " erro:getMessage(1)
    VIEW-AS ALERT-BOX ERROR BUTTONS OK.
    END CATCH.

    FINALLY:
    MESSAGE 'Execu‡Æo completa. Verifique o arquivo ' arquivo
    VIEW-AS ALERT-BOX INFO BUTTONS OK.
    END.
    lorenzi, Fujikan e fsantos curtiram isso.

Recent Reviews

  1. Fujikan
    Fujikan
    5/5,
    Version: 2014-01-20
    Mto bom
  2. fsantos
    fsantos
    5/5,
    Version: 2014-01-20
    SHOW
  3. MARCELO GIOVANETI
    MARCELO GIOVANETI
    5/5,
    Version: 2014-01-20
    Otimo