I must save on inifile as this
[section]
TH=12|normale|5|#8DB3E2|#548DD4|#FFFFFF
How I can make ?
// C:\FWH..\SAMPLES\GRABAINI.PRG - 08/10/2022 - kapiabafwh@gmail.com
#Include "FiveWin.ch"
STATIC oDlg, cTitle
FUNCTION GRABAR_INI_SILVIO()
LOCAL nCor, oIni, oFont, oIco, oBrush, oBtnClr, oBtnEnd
INI oIni FILE ".\Fondo.ini"
GET nCor SECTION "MAIN" ENTRY "Cor" OF oIni DEFAULT nCor
ENDINI
DEFINE BRUSH oBrush COLOR VAL(nCor)
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -16 BOLD
DEFINE ICON oIco FILE "..\icons\fax.ico"
cTitle := "Probando un Titulo Centrado y Fondo en un .INI"
DEFINE DIALOG oDlg FROM 100, 100 TO 500, 700 PIXEL TITLE cTitle ;
BRUSH oBrush TRANSPARENT ICON oIco FONT oFont
oDlg:lHelpIcon := .F.
@ 09.5, 17 BUTTON oBtnClr PROMPT "&Color" ACTION( SET_COLOR( oDlg ) )
oBtnClr:cToolTip := "Cambiar Color del Dialogo"
@ 09.5, 25 BUTTON oBtnEnd PROMPT "&End " ACTION( oDlg:End() ) CANCEL
oBtnEnd:cToolTip := "Salir - Exit - Cancelar"
ACTIVATE DIALOG oDlg CENTERED ON INIT( Centro() )
oFont:End()
RETURN NIL
FUNCTION Centro()
LOCAL Espacios
Espacios := ( ( ( oDlg:nWidth ) / 8 ) - ( LEN( cTitle ) ) / 2 )
oDlg:cTitle := SPACE( Espacios ) + cTitle
RETURN NIL
FUNCTION SET_COLOR( oDlg )
LOCAL oIni, oBrush, oBmp
LOCAL nTipo, cStyle, nCor := 0, cFile, cLogo, nRow, nCol, lSelect
oDlg:SetColor( oDlg:nClrText, nCor := ChooseColor( oDlg:nClrPane ) )
// Graba el Archivo .INI
INI oIni FILE ".\Fondo.ini"
SET SECTION "MAIN" ENTRY "Cor" OF oIni TO nCor
ENDINI
oDlg:Refresh()
oDlg:SetFocus()
RETURN NIL
// FIN / END
Otto wrote:Silvio, have you tried:
WritePProString( "section", "TH", "12|normale|5|#8DB3E2|#548DD4|#FFFFFF",".\demo.ini" )
Best regards,
Otto
karinha wrote:
- Code: Select all Expand view
// C:\FWH..\SAMPLES\GRABAINI.PRG - 08/10/2022 - kapiabafwh@gmail.com
#Include "FiveWin.ch"
STATIC oDlg, cTitle
FUNCTION GRABAR_INI_SILVIO()
LOCAL nCor, oIni, oFont, oIco, oBrush, oBtnClr, oBtnEnd
INI oIni FILE ".\Fondo.ini"
GET nCor SECTION "MAIN" ENTRY "Cor" OF oIni DEFAULT nCor
ENDINI
DEFINE BRUSH oBrush COLOR VAL(nCor)
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -16 BOLD
DEFINE ICON oIco FILE "..\icons\fax.ico"
cTitle := "Probando un Titulo Centrado y Fondo en un .INI"
DEFINE DIALOG oDlg FROM 100, 100 TO 500, 700 PIXEL TITLE cTitle ;
BRUSH oBrush TRANSPARENT ICON oIco FONT oFont
oDlg:lHelpIcon := .F.
@ 09.5, 17 BUTTON oBtnClr PROMPT "&Color" ACTION( SET_COLOR( oDlg ) )
oBtnClr:cToolTip := "Cambiar Color del Dialogo"
@ 09.5, 25 BUTTON oBtnEnd PROMPT "&End " ACTION( oDlg:End() ) CANCEL
oBtnEnd:cToolTip := "Salir - Exit - Cancelar"
ACTIVATE DIALOG oDlg CENTERED ON INIT( Centro() )
oFont:End()
RETURN NIL
FUNCTION Centro()
LOCAL Espacios
Espacios := ( ( ( oDlg:nWidth ) / 8 ) - ( LEN( cTitle ) ) / 2 )
oDlg:cTitle := SPACE( Espacios ) + cTitle
RETURN NIL
FUNCTION SET_COLOR( oDlg )
LOCAL oIni, oBrush, oBmp
LOCAL nTipo, cStyle, nCor := 0, cFile, cLogo, nRow, nCol, lSelect
oDlg:SetColor( oDlg:nClrText, nCor := ChooseColor( oDlg:nClrPane ) )
// Graba el Archivo .INI
INI oIni FILE ".\Fondo.ini"
SET SECTION "MAIN" ENTRY "Cor" OF oIni TO nCor
ENDINI
oDlg:Refresh()
oDlg:SetFocus()
RETURN NIL
// FIN / END
Regards, saludos.
#include "fivewin.ch"
#define MEM_FILE "test.ini"
FUNCTION Main()
RddSetDefault( "DBFCDX" )
SetHandleCount( 100 )
SET DATE FORMAT "dd-mm-yyyy"
SET DELETED ON
SET CENTURY ON
SET EPOCH TO year( date() ) - 20
SET MULTIPLE OFF
HB_LangSelect("IT")
SaveINi()
LoadIni()
RETURN nil
// save on ini file
Function SaveIni()
local cIniFile := cFilePath( GetModuleFileName( GetInstance() ) ) + MEM_FILE
local cSection
local cHeader,cData
local nFontSize_TH,nFontSize_TD
local cStyle_TH,cStyle_TD
local nSpace_TH,nSpace_TD
local nBordo_TH,nSfondo_TH,nTesto_TH
local nBordo_TD,nSfondo_TD,nTesto_TD
cSection:="HTML"
cHeader:="TH"
cData:="TD"
nFontSize_TH:= 12
nFontSize_TD:= 12
cStyle_TH:="normale"
cStyle_TD:="normale"
nSpace_TH:= 5
nSpace_TD:= 5
nBordo_TH:=#8DB3E2
nSfondo_TH:=#548DD4
nTesto_TH:=#FFFFFF
nBordo_TD:=#8DB3E2
nSfondo_TD:=#548DD4
nTesto_TD:=#FFFFFF
cString_TH:= ltrim(str(nFontSize_TH))+"|"+cStyle_TH+"|"+;
ltrim(str(nSpace_TH))+"|"+nBordo_TH+"|"+nSfondo_TH+"|"+nTesto_TH
cString_TD:= ltrim(str(nFontSize_TD))+"|"+cStyle_TD+"|"+;
ltrim(str(nSpace_TD))+"|"+nBordo_TD+"|"+nSfondo_TD+"|"+nTesto_TD
SetIni( cInifile, cSection, cHeader, cString_TH )
SetIni( cInifile, cSection, cData, cString_TD )
Return nil
//------------------------------------------------------------------------------//
Function LoadIni()
local cIniFile := cFilePath( GetModuleFileName( GetInstance() ) ) + MEM_FILE
local cString_TH,cString_TD
local cSection:="HTML"
local nFontSize_TH,nFontSize_TD
local cStyle_TH,cStyle_TD
local nSpace_TH,nSpace_TD
local nBordo_TH,nSfondo_TH,nTesto_TH
local nBordo_TD,nSfondo_TD,nTesto_TD
cString_TH:= GetIni( cInifile, cSection,"TH", "" )
cString_TD:= GetIni( cInifile, cSection,"TD", "" )
nFontSize_TH:= ?
Return nil
//---------------------------------------------------------------------------//
function SetIni( cIni, cSection, cEntry, xVar )
local oIni
INI oIni FILE cIni
set SECTION cSection ;
ENTRY cEntry ;
to xVar ;
OF oIni
ENDINI
return nil
//---------------------------------------------------------//
function GetIni( cIni, cSection, cEntry, xDefault )
local oIni
local xVar := xDefault
INI oIni FILE cIni
get xVar ;
SECTION cSection ;
ENTRY cEntry ;
default xDefault ;
OF oIni
ENDINI
return xVar
** Probando Extraer variables desde INI
** Suponiendo que las variables se alimentan desde una DBF con datos INI
** en cuyo caso x0=nombre del archivo ini tambien deberia estar guardado en la dbf
** no voy a usar x0 sino nMini para el nombre del archivo ini
#include "fivewin.ch"
MEMVAR vTini,nMini,x1,x2,x3,x4,x5,x6,x7,x8,a2,a3,a4,a5,a6,a7,a8
FUNCTION Main()
x1='TH=12|normale|5|#8DB3E2|#548DD4|#FFFFFF'
x2='TH'
x3='12'
x4='normale'
x5='5'
x6='#8DB3E2'
x7='#548DD4'
x8='#FFFFFF'
a2=LEN(x2)
a3=LEN(x3)
a4=LEN(x4)
a5=LEN(x5)
a6=LEN(x6)
a7=LEN(x7)
a8=LEN(x8)
nMini='test.ini'
SaveINi()
LoadIni()
RETU nil
FUNCTION SaveINi()
LOCAL oIni,linesay
IF FILE(nMini)
ERASE &nMini
ENDI
oIni := TTxtFile():New(nMini)
linesay='[section]'
oIni:Add(linesay)
linesay=x1
oIni:Add(linesay)
oIni:Close()
RETU nil
FUNCTION LoadIni()
LOCAL leer,nPos,nVar
STOR '' TO x2,x3,x4,x5,x6,x7,x8
leer=ALLTRIM(MEMOREAD(nMini))
msginfo(leer,'Contenido de Test.ini')
nPos=12
nVar=2
DO WHIL nPos<LEN(leer)
IF nVar=2
x2=SUBS(leer,npos,a2)
npos+=(a2+1)
nvar+=1
ELSEIF nVar=3
x3=SUBS(leer,npos,a3)
npos+=(a3+1)
nvar+=1
ELSEIF nVar=4
x4=SUBS(leer,npos,a4)
npos+=(a4+1)
nvar+=1
ELSEIF nVar=5
x5=SUBS(leer,npos,a5)
npos+=(a5+1)
nvar+=1
ELSEIF nVar=6
x6=SUBS(leer,npos,a6)
npos+=(a6+1)
nvar+=1
ELSEIF nVar=7
x7=SUBS(leer,npos,a7)
npos+=(a7+1)
nvar+=1
ELSEIF nVar=8
x8=SUBS(leer,npos,a8)
EXIT
ENDI
ENDD
msginfo('Variable 1: '+x2+CRLF+;
'Variable 2: '+x3+CRLF+;
'Variable 3: '+x4+CRLF+;
'Variable 4: '+x5+CRLF+;
'Variable 5: '+x6+CRLF+;
'Variable 6: '+x7+CRLF+;
'Variable 7: '+x8,'Dato INI Volcado a Variables')
RETU nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 98 guests