VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "ParameterClass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
'*****************************************************************************
' Module:
'        ParameterClass.cls
'-----------------------------------------------------------------------------
' Description:
'        This file contains the properties and functions of this class.
'
'-----------------------------------------------------------------------------
' History:
'                 
'        Rev. Author         Date        Description
'        ---------------------------------------------------------------------
'        1.0  ste            07.03.00    final version
'             
'
'
'*****************************************************************************


'-----------------------------------------------------
' variables for parameters
'-----------------------------------------------------
' number of parameters
Private lCount As Long
' function name (key)
Private sNameArr() As String
' function name index
Private lNameArr() As Long

' description of the parameters
Private sDescriptionArr() As String
' flag that shows if a parameter is disabled or not
Private bDisabledArr() As Boolean
' disabled tooltip text
Private sDisabledToolTipArr() As String

'-----------------------------------------------------
' adds a new parameter
'-----------------------------------------------------
Public Function AddParameter(sParameterName As String, sParmeterDescription As String) As Boolean
  On Error GoTo AddParameterError                
  
  AddParameter = False
  
  ' increment the counter
  lCount = lCount + 1

  ' redim arrays in order to add the new entry
  ReDim Preserve sNameArr(lCount)
  ReDim Preserve lNameArr(lCount)
 	Redim Preserve sDescriptionArr(lCount)
 	Redim Preserve bDisabledArr(lCount)
 	Redim Preserve sDisabledToolTipArr(lCount)

  ' set the values
  sNameArr(lCount) = sParameterName
  lNameArr(lCount) = lCount
    
 	sDescriptionArr(lCount) = sParmeterDescription

  bDisabledArr(lCount) = False
  sDisabledToolTipArr(lCount) = ""

  AddParameter = True
    
  Exit Function

AddParameterError:
    Exit Function
End Function



'-----------------------------------------------------
' sort the parameter names
'-----------------------------------------------------
Public Function Sort() As Boolean
  On Error Resume Next

  ' sort the arrays
  Sort = MergeSortStart(sNameArr, lNameArr)
End Function


'-----------------------------------------------------
' description of a parameter
'-----------------------------------------------------
Public Property Get ParameterDescription(sName As String) As String
   On Error Resume Next    
	  ParameterDescription = sDescriptionArr(SearchParameterName(sName))
End Property

Public Property Let ParameterDescription(sName As String, sNew As String)
  On Error Resume Next
 	sDescriptionArr(SearchParameterName(sName)) = sNew
End Property


'-----------------------------------------------------
' number of added parameters
'-----------------------------------------------------
Public Property Get ParameterCount As Long
	 On Error Resume Next
	 ParameterCount = UBound(sNameArr)
End Property

'-----------------------------------------------------
' disabled tooltip of a prameter
'-----------------------------------------------------
Public Property Get DisabledToolTip(sName As String) As String
   On Error Resume Next    
	  DisabledToolTip = sDisabledToolTipArr(SearchParameterName(sName))
End Property

Public Property Let DisabledToolTip(sName As String, sNew As String)
  On Error Resume Next
 	sDisabledToolTipArr(SearchParameterName(sName)) = sNew
End Property

'-----------------------------------------------------
' disabled flag
'-----------------------------------------------------
Public Property Get Disabled(sName As String) As Boolean
   On Error Resume Next    
	  Disabled = bDisabledArr(SearchParameterName(sName))
End Property

Public Property Let Disabled(sName As String, bNew As Boolean)
  On Error Resume Next
 	bDisabledArr(SearchParameterName(sName)) = bNew
End Property


'-----------------------------------------------------
' parameter name by index
'-----------------------------------------------------
Public Property Get ParameterName(lIndex As Long) As String
	 On Error Resume Next
	 ParameterName = sNameArr(lIndex)
End Property



Private Function SearchParameterName(sName As String) As Long
	Static lLastIndex As Long
	Static sLastName As String

	If (sLastName = sName) Then
		SearchParameterName = lLastIndex
	Else
		sLastName = sName
		lLastIndex = BinarySearch(sName, sNameArr, lNameArr)
		SearchParameterName = lLastIndex
	End if
End Function




'-----------------------------------------------------
' *** 
'-----------------------------------------------------
Private Sub Class_Initialize()
  On Error Resume Next
  lCount = 0
End Sub

'-----------------------------------------------------
' *** 
'-----------------------------------------------------
Private Sub Class_Terminate()
End Sub
