Skip to content

KeyExists - cIniFile

Determines whether a Key exists in a Section of an INI file

Type: Function
Return Data Type: Boolean

Parameters

Parameter Type Description
sSection String The name of the Section containing the Key
sKey String The name of the Key

Syntax

Function KeyExists String sSection String sKey Returns Boolean

Call Example

Get KeyExists sSection sKey to BooleanVariable

Description

Use the KeyExists method to determine if a Key exists before accessing it.

You must set the psFileName property to the name of the INI file before you can access it.

To see an example of how to use KeyExists, see the sample in cIniFile.

Sample

In this sample, the date is retrieved and displayed in a message box.

Object oPreferences is a cIniFile
    Procedure DoDisplayLastAccessed
        Boolean bAccessed
        String sDate

        Set psFileName To (PrimaryDataPath(self) +"\Preferences.ini")
        Get KeyExists "Last Accessed" "Date" To bAccessed
        If bAccessed Begin
            Get ReadString "Last Accessed" "Date" "" To sDate
            Send Info_Box ("Last access was: " + sDate)
        End
        Else Send Info_Box "You have not accessed the program before"
    End_Procedure
End_Object

See Also

SectionExists

Return Value

Returns True if the Key exists, False if the key does not exist or is "".