ReadSection - cIniFile
Obtains a list of Key names with an INI file Section
Type: Procedure
Parameters
| Parameter | Type | Description |
|---|---|---|
| sSection | String | [ToDo: In Progress] |
| hoArray | Handle | The object-handle of an Array instance that will store the list of Key names. |
Syntax
Procedure ReadSection String sSection Handle hoArray
Call Example
Send ReadSection sSection hoArray
Description
The ReadSection method retrieves the names of all Keys for a given Section. You pass the name of a Section and an object-handle of an Array. When the method returns, the Array object is populated with the names of the Keys.
Before using ReadSection, you must set the psFileName property to the name of the INI file.
You can obtain a list of all Section names using ReadSections.
Sample
In this sample, we test whether a Section called "Drivers" exists, and if it does we display all its Keys.
Procedure ShowKeys
Handle hoIniFile hoDrivers
Integer iDriver
// create a cIniFile object...
Get Create U_cIniFile To hoIniFile
// create an array to store the list of drivers...
Get Create U_Array To hoDrivers
Set psFileName of hoIniFile To "c:\Windows\System.ini"
If (SectionExists(hoIniFile, "Drivers")) Begin
Send ReadSection of hoIniFile "Drivers" hoDrivers
For iDriver from 0 To (Item_Count(hoDrivers) -1)
Showln iDriver " = " (Value(hoDrivers, iDriver))
Loop
End
Else ShowLn "Drivers Section does NOT exist"
// destroy the cIniFile object we just created...
Send Destroy of hoIniFile
// destroy the Array object we just created...
Send Destroy of hoDrivers
End_Procedure
See Also