Skip to content

ValueExists - cApplication

Tests whether an application-specific registry key/value exists

Type: Function
Return Data Type: Boolean

Parameters

Parameter Type Description
sSubKey String The name of an optional subkey
sValueName String The name of the Value to check the existence of

Syntax

Function ValueExists String sSubKey String sValueName Returns Boolean

Call Example

Get ValueExists sSubKey sValueName to BooleanVariable

Description

Before you attempt to read a value from the Registry, you should ensure that it exists. Use this function to verify that a Value exists before trying to read it.

The base key that will be used is that returned by RegistryKeyString and you can specify a further subkey using the sSubKey parameter. The sValueName parameter is the name of the Value to check for existence.

For example, assume that you wanted to read some preferences (which you had previously written) from the Registry at the start of your program. The "name" value is stored in the base key of your application; the "ShowCustomerView" value is stored under the "Preferences" subkey of your application. This is how you would check and retrieve the data:

Use cApplication.pkg

Object oApplication Is A cApplication

    Procedure OnCreate
        String sName
        Boolean bShowCustomerView

        If (ValueExists(Self, "", "Name")) ;
            Get ReadString "" "Name" to sName

        If (ValueExists(Self, "Preferences" "ShowCustomerView")) ;
            Get ReadInteger "Preferences" "ShowCustomerViews" to bShowCustomerView

        Send DoOpenWorkspace "MyApp"
    End_Procedure

End_Object

Return Value

True, if the Value exists. If the Value doesn't exist, then False is returned.