|
From: Alexander S.K. <al...@be...> - 2013-03-26 12:04:33
|
Yes, oGet:Settext() method changes the variable, linked to this oGet:
IF ::bSetGet != Nil
Eval( ::bSetGet, c, Self )
ENDIF
If we try to keep the type, how could we do this ? With Val() ?
IF ::bSetGet != Nil
vari := Eval( ::bSetGet, , Self )
IF Valtype(vari) == "N" .AND. Valtype(c) == "C"
Eval( ::bSetGet, Val(c), Self )
ELSE
Eval( ::bSetGet, c, Self )
ENDIF
ENDIF
But Val() may return wrong value. In your sample the Transform( 1250.21,
'999,999.99' ) will give the string "1,250.21", but the Val() of this
string returns 1 ...
So, use @ 040,050 get oDesc Var nDesc Size 100,25 picture '999,999.99'
instead.
Regards, Alexander.
Itamar M. Lins Jr. Lins writes:
> #include "hwgui.ch <http://hwgui.ch>"
>
> Function Main
> Local oDlg, oDesc, nDesc:=0
>
> INIT DIALOG oDlg CLIPPER TITLE "Test" AT 0,0 SIZE 170,190 STYLE
> DS_CENTER + WS_VISIBLE + WS_SYSMENU
>
> hwg_msginfo(Valtype(nDesc)) // Val type "N"
>
> @ 010,020 groupbox oGr CAPTION "Desconto" SIZE 150,090
> @ 040,050 get oDesc Var nDesc Size 100,25
>
> @ 030,120 Button oBt Caption 'Show' Size 100,30 ON CLICK
> {||oDesc:SetText( transform( nDesc,'999,999.99') ), hwg_EndDialog()}
> Style WS_TABSTOP
>
> oDlg:Activate()
>
>
> hwg_msginfo(Valtype(nDesc)) // Val type "C" :-(
>
> Return Nil
|