Reading from INI-file, DECIMALS are ignored ?

Reading from INI-file, DECIMALS are ignored ?

Postby ukoenig » Sat Jun 09, 2012 1:16 pm

Hello,

I noticed a Problem, reading DECIMALS from a INI-file.
Just a INTEGER-value is returned ( but saved as Decimal ).

Only got it working saving Values as String and reading like :
...
...
GET cGPosW SECTION "Skins" ENTRY "Grad-PosW" OF oIni
GET cGPosD SECTION "Skins" ENTRY "Grad-PosD" OF oIni
...
nGPosW := VAL( cGPosW )
nGPosD := VAL( cGPosD )

Decimals must be converted ?

Image

Best Regards
Uwe :?:
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Reading from INI-file, DECIMALS are ignored ?

Postby FranciscoA » Sat Jun 09, 2012 3:37 pm

ukoenig, you are right.
Many years ago, I coded a function with a get to 4 decimal places and I've always done it this way:

Function TcUSpVenta()
local nTasausPVta:=Val(GetPvProfString("config","TasaPVta","0.0000",cIniFile))

if MiGet4Dec("TCambio US$ para Ventas","","Introduzca el Tipo de Cambio US$",@nTasausPVta,"config",.t.) //4 decimals get
WritePProString("config","TasaPVta", alltrim(str(nTasausPVta)), cIniFile)
endif
Return nil

Then in another part of the code

nTcambio := val(GetPvProfString( "Config", "TasaPvta" , "1", cInifile ) )


//---------------------------------------------------------------------------
Function MiGet4Dec( cTitDlg, cTexto, aTitGet, aGet, cBmp,lDecim)
local lOK:=.F., oDlg, oBtn1, oBtn2, oBmp, oBmpF, oBrush,cBrush:=".\wall.bmp"
local oTitGet1, oTitGet2, oTitGet3, oTitGet4, oTitGet5, oSayText
local oGet1, oGet2, oGet3, oGet4, oGet5
local uTemp:=aGet

DEFAULT lDecim:=.f.

if !Empty(cBrush) .and. file(cBrush)
DEFINE BRUSH oBrush FILENAME cBrush
endif

DEFINE DIALOG oDlg RESOURCE "BUSCADOR1" TITLE cTitDlg FONT oWnd:oFont BRUSH oBrush Transparent

REDEFINE SAY oTitGet1 PROMPT aTitGet ID 101 OF oDLG
REDEFINE GET oGet1 VAR uTemp ID 201 OF oDLG PICTURE "999,999.9999"
if ! Empty( cBmp )
REDEFINE BITMAP oBmp RESOURCE cBmp ID 400 OF oDlg
endif

REDEFINE BUTTONBMP oBtn1 ID 312 OF oDLG ACTION ( lOK:=.t., oDlg:End() ) BITMAP "ACEPTAR" TEXTRIGHT
REDEFINE BUTTONBMP oBtn2 ID 313 OF oDLG ACTION ( lOK:=.f., oDlg:End() ) CANCEL BITMAP "CANCELAR" TEXTRIGHT

ACTIVATE DIALOG oDlg CENTERED

if lOK
aGet:=uTemp
endif

oBrush:End()
Return lOK

Regards.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 91 guests