Skip to content

ReadSections - cIniFile

Obtains a list of Sections names within an INI file

Type: Procedure

Parameters

Parameter Type Description
hoArray Handle The object-handle of an Array instance that will be populated with the Section names.

Syntax

Procedure ReadSections Handle hoArray

Call Example

Send ReadSections hoArray

Description

The ReadSections method retrieves the names of all Sections within an INI file. You pass an object-handle of an Array. When the method returns, the Array object is populated with the names of the Sections.

Before using ReadSections, you must set the psFileName property to the name of the INI file.

You can obtain a list of all Key names within a single Section using ReadSection.

Sample

In this sample, we display all the Section names within an INI file.

Procedure ShowSections
    Handle hoIniFile hoSections
    Integer iSection

    // create a cIniFile object...
    Get Create U_cIniFile To hoIniFile
    // create an array to store the list of drivers...
    Get Create U_Array To hoSections

    Set psFileName of hoIniFile To "c:\Windows\System.ini"
    // populate an array with the Section names...
    Send ReadSections of hoIniFile hoSections

    // show the Section names...
    For iSection from 0 To (Item_Count(hoSections) -1)
        Showln iSection " = " (Value(hoSections, iSection))
    Loop

    // destroy the cIniFile object we just created...
    Send Destroy of hoIniFile 
    // destroy the Array object we just created...
    Send Destroy of hoSections
End_Procedure

See Also

ReadSection | psFileName