xHarbour Reference Documentation > Function Reference |
Creates an INI file and writes hash data to it.
HB_WriteIni( <cFileName> , ; <hIniData> , ; [<cCommentBegin>], ; [<cCommentEnd>] , ; [<lAutoMain>] ) --> lSuccess
The function returns a logical value indicating a successful operation.
Function HB_WriteIni() writes the data held in <hIniData> to the INI file <cFileName>. If the file exists already, it is overwritten. When the file cannot be created, the return value is .F. (false) and function FError() can be called to identify the cause of failure.
INI files provide a convenient way for storing configuration data of an application. They are divided into named [sections] holding key/value pairs. An example for an INI file is this:
; Start comment Desc = Application program Ver = Version 2.2 [Files] DB1=Customer.dbf DB2=Sales.dbf [Path] CONFIG=\apps\conf\ DATA=\apps\data\ ; End comment
This INI file contains six key/value pairs, divided into three [sections]. The first section is unnamed. It has the default name "MAIN".
See also: | FCreate(), FWrite(), Hash(), HB_SetIniComment(), HB_ReadIni() |
Category: | File functions , xHarbour extensions |
Source: | rtl\hbini.prg |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates how an INI file can be created // programmatically by creating a two-dimensional Hash. The // INI file shown in the function description is created by // the example. PROCEDURE Main LOCAL hIni := Hash() hIni["MAIN" ] := Hash() hIni["MAIN" ]["Desc" ] := "Application program" hIni["MAIN" ]["Ver" ] := "Version 2.2" hIni["Path" ] := Hash() hIni["Path" ]["DATA"] := "\apps\data\" hIni["Path" ]["CONFIG"] := "\apps\conf\" hIni["Files"] := Hash() hIni["Files"]["DB1"] := "Customer.dbf" hIni["Files"]["DB2"] := "Sales.dbf" HB_WriteIni( "Application.ini", hIni, ; "; Start comment", "; End comment" ) RETURN
http://www.xHarbour.com