Problema Arredondar

Discussão em 'Progress 4GL' iniciado por lorenzi, Julho 15, 2013.

  1. lorenzi

    lorenzi Membro Participativo

    Pessoal, ja fiz o codigo que lhes mostro de varias formas so que nao tem jeito do infeliz mostrar o valor sem arredondar:

    Tipo: Qtdade = 50000 / Total = 6999,75 = 0,139995 so que na tela sempre joga 0,14 alguém da uma ajuda ai , abaixo o código é um programa gráfico.

    Código:
    &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v9r12 GUI
    &ANALYZE-RESUME
    &Scoped-define WINDOW-NAME C-Win
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS C-Win 
    /*------------------------------------------------------------------------
    
      File: 
    
      Description: 
    
      Input Parameters:
          <none>
    
      Output Parameters:
          <none>
    
      Author: 
    
      Created: 
    
    ------------------------------------------------------------------------*/
    /*          This .W file was created with the Progress AppBuilder.      */
    /*----------------------------------------------------------------------*/
    
    /* Create an unnamed pool to store all the widgets created 
         by this procedure. This is a good default which assures
         that this procedure's triggers and internal procedures 
         will execute in this procedure's storage, and that proper
         cleanup will occur on deletion of the procedure. */
    
    CREATE WIDGET-POOL.
    
    /* ***************************  Definitions  ************************** */
    
    /* Parameters Definitions ---                                           */
    
    /* Local Variable Definitions ---                                       */
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 
    
    /* ********************  Preprocessor Definitions  ******************** */
    
    &Scoped-define PROCEDURE-TYPE Window
    &Scoped-define DB-AWARE no
    
    /* Name of first Frame and/or Browse and/or first Query                 */
    &Scoped-define FRAME-NAME f
    
    /* Standard List Definitions                                            */
    &Scoped-Define ENABLED-OBJECTS v-qtd v-uni v-total BUTTON-128 
    &Scoped-Define DISPLAYED-OBJECTS v-qtd v-uni v-total 
    
    /* Custom List Definitions                                              */
    /* List-1,List-2,List-3,List-4,List-5,List-6                            */
    
    /* _UIB-PREPROCESSOR-BLOCK-END */
    &ANALYZE-RESUME
    
    
    
    /* ***********************  Control Definitions  ********************** */
    
    /* Define the widget handle for the window                              */
    DEFINE VAR C-Win AS WIDGET-HANDLE NO-UNDO.
    
    /* Definitions of the field level widgets                               */
    DEFINE BUTTON BUTTON-128 
         LABEL "Button 128" 
         SIZE 15 BY 1.14.
    
    DEFINE VARIABLE v-qtd AS DECIMAL FORMAT "->>,>>9.9999":U INITIAL 50000 
         LABEL "Fill 1" 
         VIEW-AS FILL-IN 
         SIZE 35 BY 1 NO-UNDO.
    
    DEFINE VARIABLE v-total AS DECIMAL FORMAT "->>,>>9.99":U INITIAL 6999.75 
         LABEL "Fill 3" 
         VIEW-AS FILL-IN 
         SIZE 35 BY 1 NO-UNDO.
    
    DEFINE VARIABLE v-uni AS DECIMAL FORMAT "->>,>>9.9999":U INITIAL 0 
         LABEL "Fill 2" 
         VIEW-AS FILL-IN 
         SIZE 35 BY 1 NO-UNDO.
    
    
    /* ************************  Frame Definitions  *********************** */
    
    DEFINE FRAME f
         v-qtd AT ROW 2.67 COL 16 COLON-ALIGNED
         v-uni AT ROW 3.86 COL 16 COLON-ALIGNED
         v-total AT ROW 5.05 COL 16 COLON-ALIGNED
         BUTTON-128 AT ROW 11 COL 30
        WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY 
             SIDE-LABELS NO-UNDERLINE THREE-D 
             AT COL 1 ROW 1
             SIZE 80 BY 16.
    
    
    /* *********************** Procedure Settings ************************ */
    
    &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
    /* Settings for THIS-PROCEDURE
       Type: Window
       Allow: Basic,Browse,DB-Fields,Window,Query
       Other Settings: COMPILE
     */
    &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
    
    /* *************************  Create Window  ************************** */
    
    &ANALYZE-SUSPEND _CREATE-WINDOW
    IF SESSION:DISPLAY-TYPE = "GUI":U THEN
      CREATE WINDOW C-Win ASSIGN
             HIDDEN             = YES
             TITLE              = "<insert window title>"
             HEIGHT             = 16
             WIDTH              = 80
             MAX-HEIGHT         = 16
             MAX-WIDTH          = 80
             VIRTUAL-HEIGHT     = 16
             VIRTUAL-WIDTH      = 80
             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                                                */
    &ANALYZE-RESUME
    
    
    
    /* ***********  Runtime Attributes and AppBuilder Settings  *********** */
    
    &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
    /* SETTINGS FOR WINDOW C-Win
      VISIBLE,,RUN-PERSISTENT                                               */
    /* SETTINGS FOR FRAME f
                                                                            */
    IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(C-Win)
    THEN C-Win:HIDDEN = no.
    
    /* _RUN-TIME-ATTRIBUTES-END */
    &ANALYZE-RESUME
    
     
    
    
    
    /* ************************  Control Triggers  ************************ */
    
    &Scoped-define SELF-NAME C-Win
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL C-Win C-Win
    ON END-ERROR OF C-Win /* <insert window title> */
    OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
      /* This case occurs when the user presses the "Esc" key.
         In a persistently run window, just ignore this.  If we did not, the
         application would exit. */
      IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
    END.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL C-Win C-Win
    ON WINDOW-CLOSE OF C-Win /* <insert window title> */
    DO:
      /* This event will close the window and terminate the procedure.  */
      APPLY "CLOSE":U TO THIS-PROCEDURE.
      RETURN NO-APPLY.
    END.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    &Scoped-define SELF-NAME BUTTON-128
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL BUTTON-128 C-Win
    ON CHOOSE OF BUTTON-128 IN FRAME f /* Button 128 */
    DO:
        MESSAGE round(INPUT FRAME f v-total,4) / round(INPUT FRAME f v-qtd,4)
            VIEW-AS ALERT-BOX INFO BUTTONS OK.
        DISP DEC((round(INPUT FRAME f v-total,4) / round(INPUT FRAME f v-qtd,4))) @ v-uni WITH FRAME f.
        
    END.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    &UNDEFINE SELF-NAME
    
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK C-Win 
    
    
    /* ***************************  Main Block  *************************** */
    
    /* 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.
    MESSAGE  session:NUMERIC-FORMAT VIEW-AS ALERT-BOX.
    /* 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.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    /* **********************  Internal Procedures  *********************** */
    
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI C-Win  _DEFAULT-DISABLE
    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.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI C-Win  _DEFAULT-ENABLE
    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.
    ------------------------------------------------------------------------------*/
      DISPLAY v-qtd v-uni v-total 
          WITH FRAME f IN WINDOW C-Win.
      ENABLE v-qtd v-uni v-total BUTTON-128 
          WITH FRAME f IN WINDOW C-Win.
      {&OPEN-BROWSERS-IN-QUERY-f}
      VIEW C-Win.
    END PROCEDURE.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    
  2. Rogerio

    Rogerio Moderator Moderador Equipe de Suporte

    Bom dia, tente alterar a linha do seu DISP para:

    DISP string(DEC(INPUT FRAME f v-total) / dec(INPUT FRAME f v-qtd)) @ v-uni WITH FRAME f.
  3. lorenzi

    lorenzi Membro Participativo

    Assim rola, valeu. So nao entendo pq nao funciona diretamente.
  4. lorenzi

    lorenzi Membro Participativo

    Pessoal deu outro problema agora, o campo setou mas se pegar o valor dele e jogar em outro campo ele arredonda mesma coisa.

    Código:
    &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v9r12 GUI
    &ANALYZE-RESUME
    &Scoped-define WINDOW-NAME C-Win
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS C-Win 
    /*------------------------------------------------------------------------
    
      File: 
    
      Description: 
    
      Input Parameters:
          <none>
    
      Output Parameters:
          <none>
    
      Author: 
    
      Created: 
    
    ------------------------------------------------------------------------*/
    /*          This .W file was created with the Progress AppBuilder.      */
    /*----------------------------------------------------------------------*/
    
    /* Create an unnamed pool to store all the widgets created 
         by this procedure. This is a good default which assures
         that this procedure's triggers and internal procedures 
         will execute in this procedure's storage, and that proper
         cleanup will occur on deletion of the procedure. */
    
    CREATE WIDGET-POOL.
    
    /* ***************************  Definitions  ************************** */
    
    /* Parameters Definitions ---                                           */
    
    /* Local Variable Definitions ---                                       */
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 
    
    /* ********************  Preprocessor Definitions  ******************** */
    
    &Scoped-define PROCEDURE-TYPE Window
    &Scoped-define DB-AWARE no
    
    /* Name of first Frame and/or Browse and/or first Query                 */
    &Scoped-define FRAME-NAME f
    
    /* Standard List Definitions                                            */
    &Scoped-Define ENABLED-OBJECTS v-qtd v-uni v-total F2 BUTTON-128 
    &Scoped-Define DISPLAYED-OBJECTS v-qtd v-uni v-total F2 
    
    /* Custom List Definitions                                              */
    /* List-1,List-2,List-3,List-4,List-5,List-6                            */
    
    /* _UIB-PREPROCESSOR-BLOCK-END */
    &ANALYZE-RESUME
    
    
    
    /* ***********************  Control Definitions  ********************** */
    
    /* Define the widget handle for the window                              */
    DEFINE VAR C-Win AS WIDGET-HANDLE NO-UNDO.
    
    /* Definitions of the field level widgets                               */
    DEFINE BUTTON BUTTON-128 
         LABEL "Button 128" 
         SIZE 15 BY 1.14.
    
    DEFINE VARIABLE F2 AS DECIMAL FORMAT "->>,>>9.9999":U INITIAL 0 
         LABEL "Fill 2" 
         VIEW-AS FILL-IN 
         SIZE 14 BY 1 NO-UNDO.
    
    DEFINE VARIABLE v-qtd AS DECIMAL FORMAT "->>,>>9.9999":U INITIAL 50000 
         LABEL "Fill 1" 
         VIEW-AS FILL-IN 
         SIZE 35 BY 1 NO-UNDO.
    
    DEFINE VARIABLE v-total AS DECIMAL FORMAT "->>,>>9.99":U INITIAL 6999.75 
         LABEL "Fill 3" 
         VIEW-AS FILL-IN 
         SIZE 35 BY 1 NO-UNDO.
    
    DEFINE VARIABLE v-uni AS DECIMAL FORMAT "->>,>>9.9999":U INITIAL 0 
         LABEL "Fill 2" 
         VIEW-AS FILL-IN 
         SIZE 35 BY 1 NO-UNDO.
    
    
    /* ************************  Frame Definitions  *********************** */
    
    DEFINE FRAME f
         v-qtd AT ROW 2.67 COL 16 COLON-ALIGNED
         v-uni AT ROW 3.86 COL 16 COLON-ALIGNED
         v-total AT ROW 5.05 COL 16 COLON-ALIGNED
         F2 AT ROW 6.24 COL 16 COLON-ALIGNED
         BUTTON-128 AT ROW 8.62 COL 31
        WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY 
             SIDE-LABELS NO-UNDERLINE THREE-D 
             AT COL 1 ROW 1
             SIZE 80 BY 16.
    
    
    /* *********************** Procedure Settings ************************ */
    
    &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
    /* Settings for THIS-PROCEDURE
       Type: Window
       Allow: Basic,Browse,DB-Fields,Window,Query
       Other Settings: COMPILE
     */
    &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
    
    /* *************************  Create Window  ************************** */
    
    &ANALYZE-SUSPEND _CREATE-WINDOW
    IF SESSION:DISPLAY-TYPE = "GUI":U THEN
      CREATE WINDOW C-Win ASSIGN
             HIDDEN             = YES
             TITLE              = "<insert window title>"
             HEIGHT             = 16
             WIDTH              = 80
             MAX-HEIGHT         = 16
             MAX-WIDTH          = 80
             VIRTUAL-HEIGHT     = 16
             VIRTUAL-WIDTH      = 80
             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                                                */
    &ANALYZE-RESUME
    
    
    
    /* ***********  Runtime Attributes and AppBuilder Settings  *********** */
    
    &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
    /* SETTINGS FOR WINDOW C-Win
      VISIBLE,,RUN-PERSISTENT                                               */
    /* SETTINGS FOR FRAME f
                                                                            */
    IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(C-Win)
    THEN C-Win:HIDDEN = no.
    
    /* _RUN-TIME-ATTRIBUTES-END */
    &ANALYZE-RESUME
    
     
    
    
    
    /* ************************  Control Triggers  ************************ */
    
    &Scoped-define SELF-NAME C-Win
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL C-Win C-Win
    ON END-ERROR OF C-Win /* <insert window title> */
    OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
      /* This case occurs when the user presses the "Esc" key.
         In a persistently run window, just ignore this.  If we did not, the
         application would exit. */
      IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
    END.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL C-Win C-Win
    ON WINDOW-CLOSE OF C-Win /* <insert window title> */
    DO:
      /* This event will close the window and terminate the procedure.  */
      APPLY "CLOSE":U TO THIS-PROCEDURE.
      RETURN NO-APPLY.
    END.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    &Scoped-define SELF-NAME BUTTON-128
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL BUTTON-128 C-Win
    ON CHOOSE OF BUTTON-128 IN FRAME f /* Button 128 */
    DO:
       /* MESSAGE round(INPUT FRAME f v-total,4) / round(INPUT FRAME f v-qtd,4)
            VIEW-AS ALERT-BOX INFO BUTTONS OK. */
        DISP  string(DEC(INPUT FRAME f v-total) / dec(INPUT FRAME f v-qtd)) @ v-uni 
              INPUT FRAME f v-uni @ f2 WITH FRAME f.
        
    END.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    &UNDEFINE SELF-NAME
    
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK C-Win 
    
    
    /* ***************************  Main Block  *************************** */
    
    /* 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.
    MESSAGE  session:NUMERIC-FORMAT VIEW-AS ALERT-BOX.
    /* 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.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    /* **********************  Internal Procedures  *********************** */
    
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI C-Win  _DEFAULT-DISABLE
    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.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI C-Win  _DEFAULT-ENABLE
    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.
    ------------------------------------------------------------------------------*/
      DISPLAY v-qtd v-uni v-total F2 
          WITH FRAME f IN WINDOW C-Win.
      ENABLE v-qtd v-uni v-total F2 BUTTON-128 
          WITH FRAME f IN WINDOW C-Win.
      {&OPEN-BROWSERS-IN-QUERY-f}
      VIEW C-Win.
    END PROCEDURE.
    
    /* _UIB-CODE-BLOCK-END */
    &ANALYZE-RESUME
    
    
    

Compartilhe esta Página