SOLUCIONADO, (SAY .. PICTURE error en decimales)

SOLUCIONADO, (SAY .. PICTURE error en decimales)

Postby albeiroval » Mon Sep 07, 2020 5:34 am

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
Last edited by albeiroval on Tue Sep 08, 2020 2:40 am, edited 1 time in total.
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 359
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: SAY .. PICTURE error en decimales

Postby karinha » Mon Sep 07, 2020 12:40 pm

Este código no compila... Haga un ejemplo completo.

Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: SAY .. PICTURE error en decimales

Postby albeiroval » Mon Sep 07, 2020 1:08 pm

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

 
 
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 359
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: SAY .. PICTURE error en decimales

Postby JESUS MARIN » Mon Sep 07, 2020 4:57 pm

Saludos

a mi, me da muchos errores.

voy a revisarlo
Jesús Marín
JESUS MARIN
 
Posts: 174
Joined: Wed Jan 02, 2019 8:36 am

Re: SAY .. PICTURE error en decimales

Postby karinha » Mon Sep 07, 2020 5:10 pm

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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: SAY .. PICTURE error en decimales

Postby JESUS MARIN » Mon Sep 07, 2020 5:40 pm

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
 
Jesús Marín
JESUS MARIN
 
Posts: 174
Joined: Wed Jan 02, 2019 8:36 am

Re: SAY .. PICTURE error en decimales

Postby albeiroval » Mon Sep 07, 2020 7:26 pm

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.
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 359
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: SAY .. PICTURE error en decimales

Postby karinha » Tue Sep 08, 2020 12:27 am

Cual versión del five? Reporte para mister Cristóbal, porfa.

Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: SAY .. PICTURE error en decimales

Postby albeiroval » Tue Sep 08, 2020 12:47 am

fwh 12.19
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 359
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: SAY .. PICTURE error en decimales

Postby nageswaragunupudi » Tue Sep 08, 2020 1:02 am

albeiroval wrote:fwh 12.19


There is no version FWH1219.

Do you mean December 2019?

That is FWH1912 ?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: SAY .. PICTURE error en decimales

Postby albeiroval » Tue Sep 08, 2020 1:58 am

That is FWH1912 ?


sorry for my mistake, the version is fwh19.12
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 359
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: SAY .. PICTURE error en decimales

Postby nageswaragunupudi » Tue Sep 08, 2020 2:25 am

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
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: SAY .. PICTURE error en decimales

Postby albeiroval » Tue Sep 08, 2020 2:39 am

Thank you very much Mr. RAO, it works perfectly

Muchas gracias Mr. RAO, funciona perfectamente

:D
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 359
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 88 guests