Page 1 of 1
tget only numbers and "."
Posted: Wed Nov 09, 2022 9:37 am
by Silvio.Falconi
the user can digit only number and "." on a get
LOCAL oGet, cvar := Space(100)
@ 82, 2 GET oGet VAR cVar SIZE 200,20 PIXEL OF oBarRight NOBORDER FONT oFontGet
oGet:bChange := {|nKey|(Chr(nKey)$"0123456789.")}
why I can insert also characters ? (as you see in this picture )

Re: tget only numbers
Posted: Wed Nov 09, 2022 10:30 am
by Jimmy
hi Silvo,
Silvio.Falconi wrote:the user can digit only number and "." on a get
what about using cPicture "99"

Re: tget only numbers
Posted: Wed Nov 09, 2022 12:28 pm
by karinha
Algo asi?
Code: Select all | Expand
// C:\FWH..\SAMPLES\SILVGETN.PRG
#Include "FiveWin.ch"
STATIC oDlg, oFont
FUNCTION Main()
LOCAL oGet, cVar := Space(100)
LOCAL oBtnX2, cTitle, aGrad, oSay
cTitle := "Cambia GET"
DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 14
DEFINE DIALOG oDlg SIZE 600, 200 PIXEL TRUEPIXEL RESIZABLE ;
TITLE cTitle GRADIENT aGrad FONT oFont
oDlg:lHelpIcon := .F.
@ 12, 2 GET oGet VAR cVar SIZE 200,20 PIXEL OF oDlg FONT oFont ;
PICTURE "@R 99,999,999,999.99"
ACTIVATE DIALOG oDlg CENTERED ON INIT( CAMBIA_PICT( oGet ) )
RETURN NIL
FUNCTION CAMBIA_PICT( oGet )
LOCAL cPict := "012345678912"
oGet:VARPUT( cPict )
oGet:Refresh()
RETURN( .T. )
// FIN / END
Regards, saludos.
Re: tget only numbers
Posted: Wed Nov 09, 2022 12:40 pm
by Silvio.Falconi
karinha wrote:Algo asi?
Code: Select all | Expand
// C:\FWH..\SAMPLES\SILVGETN.PRG
#Include "FiveWin.ch"
STATIC oDlg, oFont
FUNCTION Main()
LOCAL oGet, cVar := Space(100)
LOCAL oBtnX2, cTitle, aGrad, oSay
cTitle := "Cambia GET"
DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 14
DEFINE DIALOG oDlg SIZE 600, 200 PIXEL TRUEPIXEL RESIZABLE ;
TITLE cTitle GRADIENT aGrad FONT oFont
oDlg:lHelpIcon := .F.
@ 12, 2 GET oGet VAR cVar SIZE 200,20 PIXEL OF oDlg FONT oFont ;
PICTURE "@R 99,999,999,999.99"
ACTIVATE DIALOG oDlg CENTERED ON INIT( CAMBIA_PICT( oGet ) )
RETURN NIL
FUNCTION CAMBIA_PICT( oGet )
LOCAL cPict := "012345678912"
oGet:VARPUT( cPict )
oGet:Refresh()
RETURN( .T. )
// FIN / END
Regards, saludos.
NO
I must write a string no a price
I must write also "." sample: 36.67.80.7.3.23.45 and not PICTURE "@R 99,999,999,999.99"
because the tget control is read by a procedure that finds the numbers in the xbrowse and colors them as you can see here
oGet:bChange := {|nKey|(Chr(nKey)$"0123456789.")}
oGet:bKeyDown := { | nKey |(oGet:assign(), ActiveNavigator(cVar,oBrw,oItem2:lChecked)) }

Re: tget only numbers and "."
Posted: Wed Nov 09, 2022 1:33 pm
by karinha
Re: tget only numbers and "."
Posted: Wed Nov 09, 2022 3:42 pm
by Silvio.Falconi
I not know the config of string
Can be 36.6 or 45.66 .78 or more numbers
Chat Is space(100)
Perhaps U not understood my problem
Re: tget only numbers and "."
Posted: Thu Nov 10, 2022 4:21 am
by nageswaragunupudi
Code: Select all | Expand
oGet:bKeyChar := { |k| If( chr( k ) $ ".0123456789", nil, 0 ) }
Re: tget only numbers and "."
Posted: Thu Nov 10, 2022 6:15 am
by Silvio.Falconi
nageswaragunupudi wrote:Code: Select all | Expand
oGet:bKeyChar := { |k| If( chr( k ) $ ".0123456789", nil, 0 ) }
Thanks rao