Previous Topic: WriteIniEntry - Store a Value in an .ini fileNext Topic: ReadIniEntry - Retrieve a Value from a Specified Section


WriteIniSection - Create or Overwrite an Entire Section

Valid on UNIX and Windows

The WriteIniSection function creates or overwrites an entire section in a specific initialization (.ini) file. If the .ini file does not exist, this function creates it.

Function format:

WriteIniSection(section as String, value as String, filename as String) as Boolean
section

Identifies the name of the section to be written.

value

Identifies the entries to be written. The entries in value must have the following format:

Entry_1 = Value_1 <LF>
Entry_n = Value_n <LF>
filename

Specifies the name of the initialization file.

On successful completion, the function returns TRUE; otherwise, returns FALSE.

Example:

Dim entries as String
Dim LF as String
LF = chr(10)
entries = "Entry_1 = Value_1" + LF + "Entry_n = Value_n"
Rem	this example writes to c:\temp\test.ini the section LIST

Dim attrList as String

lf = chr(10)
attrList = "Entry_1=Value_1"+lf+"Entry_2=Value_2"

If Not(WriteIniSection("LIST", attrList, "c:\temp\test.ini")) Then
	MessageBox("Can not create LIST section", "DMS", MB_OK + MB_ICONEXCLAMATION)
	SetStatus(1)
	Exit
End If