ValueExists - cApplication

Tests whether an application-specific registry key/value exists

Type: Function

Return Data Type: Boolean

Parameters: string sSubKey string sValueName

ParameterDescription
sSubKeyThe name of an optional subkey
sValueNameThe name of the Value to check the existence of


Return Value

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


Syntax
Function ValueExists string sSubKey string sValueName Returns Boolean

Call: 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