Page 1 of 1

SOLUCIONADO, (SAY .. PICTURE error en decimales)

PostPosted: Mon Sep 07, 2020 5:34 am
by albeiroval
Hola,

Necesito que un control SAY muestre el valor numerico que contiene el control GET,
logre hacerlo solamente con la parte entera, pero con los decimales no lo hace.

Code: Select all  Expand view


#define TO_PICTURE := "@E 999,999,999,999.99"

static lfirst := .T.

...

@ 1.6, 4 GET oGet VAR uTemp SIZE 120, 12 OF oDlg
@ 3.6, 4 SAY oSay PROMPT "" SIZE 120, 12 OF oDlg PICTURE TO_PICTURE

ACTIVATE DIALOG oDlg;
     CENTERED;
     ON INIT OnInitMsgGetEx( oGet, oDlg, oSay )

static Function OnInitMsgGetEx( oGet, oDlg, oSay )
   
     oGet:cPicture = TO_PICTURE
     oGet:bKeyChar = <|k,f,o|
                      Local cBuffer := ""
                   
                        if lfirst
                           lfirst := .F.
                             SetWindowText( oSay:hWnd, "")                      
                             Return Nil
                        endif
                             
                      cbuffer := strtran(o:oGet:buffer, ",", "")
                      cbuffer := AllTrim(cbuffer)
                      cbuffer := cbuffer + Chr(k)
                      cbuffer := Val(cbuffer)
                      SetWindowText( oSay:hWnd, Transform( cbuffer, TO_PICTURE) )
                                           
                      Return Nil
                    >
              
Return Nil                


 


[img]
https://i.postimg.cc/SxpRCzhC/get.png
[/img]

Saludos

Re: SAY .. PICTURE error en decimales

PostPosted: Mon Sep 07, 2020 12:40 pm
by karinha
Este código no compila... Haga un ejemplo completo.

Saludos.

Re: SAY .. PICTURE error en decimales

PostPosted: Mon Sep 07, 2020 1:08 pm
by albeiroval
Hola karinha,

Aqui el ejemplo completo.

Code: Select all  Expand view

#include "fivewin.ch"

#define TO_PICTURE "@E 999,999,999,999.99"

static lfirst := .T.

function main()

    local oDlg, oGet, oBmp, oFont
  local oSay
  local oBtn  := Array(2)
  local uTemp := 0
  local lOk   := .f.
   
    DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12 BOLD

  DEFINE DIALOG oDlg FROM 10, 20 TO 20, 59.5 TITLE "TEST" FONT oFont

    @ 1.6, 4 GET oGet VAR uTemp SIZE 120, 12 OF oDlg
    @ 2.3, 4 SAY oSay PROMPT "" SIZE 120, 12 OF oDlg PICTURE TO_PICTURE
   
    @ 2.90, 7.5 - If( oBmp == Nil, 2, 0 ) BUTTON oBtn[1] PROMPT "&Aceptar"  OF oDlg SIZE 35, 12 ;
    ACTION ( oDlg:End(), lOk := .t. ) DEFAULT

  @ 2.90, 16.5 - If( oBmp == Nil, 2, 0 ) BUTTON oBtn[2] PROMPT "&Salir" OF oDlg SIZE 35, 12 ;
    ACTION ( oDlg:End(), lOk := .f. )
     

    ACTIVATE DIALOG oDlg;
     CENTERED;
     ON INIT OnInitMsgGetEx( oGet, oDlg, oSay )
     
Return Nil    

static Function OnInitMsgGetEx( oGet, oDlg, oSay )
   
    oGet:cPicture = TO_PICTURE
  oGet:bKeyChar = <|k,f,o|
                                    Local cBuffer := ""
                   
                    if lfirst
                         lfirst := .F.
                       SetWindowText( oSay:hWnd, "")                      
                       Return Nil
                    endif
                             
                    cbuffer := strtran(o:oGet:buffer, ",", "")
                    cbuffer := AllTrim(cbuffer)
                    cbuffer := cbuffer + Chr(k)
                    cbuffer := Val(cbuffer)
                    SetWindowText( oSay:hWnd, Transform( cbuffer, TO_PICTURE) )
                                           
                    Return Nil
                   >
             
Return Nil                

// FINAL

 
 

Re: SAY .. PICTURE error en decimales

PostPosted: Mon Sep 07, 2020 4:57 pm
by JESUS MARIN
Saludos

a mi, me da muchos errores.

voy a revisarlo

Re: SAY .. PICTURE error en decimales

PostPosted: Mon Sep 07, 2020 5:10 pm
by karinha
Code: Select all  Expand view

// SAMPLES\ALBEROVA.PRG - Nunca me complico con Fivewin.

#Include "FiveWin.ch"

#Define TO_PICTURE "@E 999,999,999,999.99"

STATIC lfirst := .T.

FUNCTION Main()

   LOCAL oDlg, oGet, oBmp, oFont, oSay
   LOCAL oBtn  := Array( 2 )
   LOCAL uTemp := 0
   LOCAL lOk   := .F.

   SET DECIMALS TO 2
   
   DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 12 BOLD

   DEFINE DIALOG oDlg FROM 10, 20 TO 20, 59.5 TITLE "TEST" FONT oFont

   oDlg:lHelpIcon := .F.

   @ 1.6, 4 GET oGet VAR uTemp SIZE 120, 12 OF oDlg UPDATE ;
      ON CHANGE Cambia_Say_Tiempo_Real( oGet, oDlg, oSay )

   @ 2.3, 4 SAY oSay PROMPT "" SIZE 120, 12 OF oDlg UPDATE
   
   @ 2.90, 7.5 - If( oBmp == NIL, 2, 0 ) BUTTON oBtn[1] PROMPT "&Aceptar"  ;
      OF oDlg SIZE 35, 12 ACTION ( oDlg:End(), lOk := .T. ) DEFAULT

   @ 2.90, 16.5 - If( oBmp == NIL, 2, 0 ) BUTTON oBtn[2] PROMPT "&Salir"   ;
      OF oDlg SIZE 35, 12 ACTION ( oDlg:End(), lOk := .F. ) CANCEL
     
   ACTIVATE DIALOG oDlg CENTERED
     
RETURN NIL

FUNCTION Cambia_Say_Tiempo_Real( oGet, oDlg, oSay )

   LOCAL cVar, nCampo
   LOCAL cPicture := TO_PICTURE

   oGet:cPicture     := TO_PICTURE
   oGet:oGet:Picture := TO_PICTURE

   cVar   := oGet:GetText()
   nCampo := ALLTRIM( cVar )

   TRANSF( nCampo, cPicture )

   oSay:VARPUT( nCampo )
   oSay:Refresh()

RETURN( .T. )

// FINAL - kapiabafwh@gmail.com
 


Regards, saludos.

Re: SAY .. PICTURE error en decimales

PostPosted: Mon Sep 07, 2020 5:40 pm
by JESUS MARIN
Prueba este, super simple.

Code: Select all  Expand view


#include "fivewin.ch"

#define TO_PICTURE "@E 999,999,999,999.99"


function main()

  local oDlg, oGet, uTemp:=0.00, oFont, oSay, cSay:="", oBtn

  DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12

  DEFINE DIALOG oDlg FROM 10, 20 TO 20, 59.5 TITLE "TEST" FONT oFont

    @ 1.6, 4 GET oGet VAR uTemp SIZE 120, 12 OF oDlg

    @ 2.3, 4 SAY oSay VAR cSay  SIZE 120, 12 OF oDlg UPDATE

    @ 3,2  BUTTON oBtn PROMPT "&Aceptar"  OF oDlg SIZE 35, 12 ACTION oDlg:End()


    oGet:bChange:={ || oSay:SetText(Transform( uTemp, TO_PICTURE)) }

    ACTIVATE DIALOG oDlg

Return Nil
 

Re: SAY .. PICTURE error en decimales

PostPosted: Mon Sep 07, 2020 7:26 pm
by albeiroval
Chicos gracias por responder,
Ninguno de los 2 ejemplos funciona.

Jesus, probe tu ejemplo y no hace lo que necesito. La idea es la siguiente:
cuando se este tecleando el numero en el GET en el mismo momento(en linea)
muestre el resultado en el campo SAY.

Karinha, raro que no compile el ejemplo que te envie. En cuanto al ejemplo
que pusiste NO funciona con los decimales y en el GET los
millares los separa con espacio (no deberia verse asi), y cuando usas la tecla backspace (retroceso)
el buffer del GET no trabaja bien.

Gracias a ambos.

Re: SAY .. PICTURE error en decimales

PostPosted: Tue Sep 08, 2020 12:27 am
by karinha
Cual versión del five? Reporte para mister Cristóbal, porfa.

Saludos.

Re: SAY .. PICTURE error en decimales

PostPosted: Tue Sep 08, 2020 12:47 am
by albeiroval
fwh 12.19

Re: SAY .. PICTURE error en decimales

PostPosted: Tue Sep 08, 2020 1:02 am
by nageswaragunupudi
albeiroval wrote:fwh 12.19


There is no version FWH1219.

Do you mean December 2019?

That is FWH1912 ?

Re: SAY .. PICTURE error en decimales

PostPosted: Tue Sep 08, 2020 1:58 am
by albeiroval
That is FWH1912 ?


sorry for my mistake, the version is fwh19.12

Re: SAY .. PICTURE error en decimales

PostPosted: Tue Sep 08, 2020 2:25 am
by nageswaragunupudi
Is this what you want?
Image

This is the sample code with FWH1912:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oFont, oGet, oSay, cVal, nVal := 0.0
   local nSay  := nVal
   local cPic  := "@E 999,999,999,999.99"

   SetGetColorFocus()

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-20
   DEFINE DIALOG oDlg SIZE 300,200 PIXEL FONT oFont TITLE FWVERSION

   @ 10,10 GET oGet VAR nVal PICTURE cPic SIZE 100,16 PIXEL OF oDlg RIGHT ;
      VALID ( nSay := nVal, oDlg:Update(), .t. )

   oGet:bChange := <|k|
      if oGet:oGet:buffer != nil
         nSay  := Val( StrTran( oGet:oGet:buffer, ",", "." ) )
         oDlg:Update()
      endif
      return .t.
      >

   @ 30,10 SAY oSay PROMPT { || nSay } PICTURE cPic SIZE 98,14 PIXEL OF oDlg RIGHT UPDATE

   @ 60,10 BUTTON "OK" SIZE 40,20 PIXEL OF oDlg

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
 

Re: SAY .. PICTURE error en decimales

PostPosted: Tue Sep 08, 2020 2:39 am
by albeiroval
Thank you very much Mr. RAO, it works perfectly

Muchas gracias Mr. RAO, funciona perfectamente

:D