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

Private Type TLink
  sDefSection As String
  sLinkName As String
  sKeyName As String
  bGroup As Boolean
End Type

Private Type TManualMenu
  sScriptName As String
  Link() As TLink
  lLinkCounter As Long
End Type

'-----------------------------------------------------
' private variables
'-----------------------------------------------------
' number of added Manual Menus
Private lMenuCounter As Long
' 
Private m() As TManualMenu



Public Property Get ScriptName(lMenuIndex As Long) As String
	 On Error Resume Next
	 ScriptName = m(lMenuIndex).sScriptName
End Property

Public Property Let ScriptName(lMenuIndex As Long, sName As String)
	 On Error Resume Next
	 m(lMenuIndex).sScriptName = sName
End Property


Public Property Get MenuCounter() As Long
	 On Error Resume Next
	 MenuCounter = lMenuCounter
End Property


Public Property Get LinkCounter(lMenuIndex As Long) As Long
	 On Error Resume Next
	 LinkCounter = m(lMenuIndex).lLinkCounter
End Property


Public Property Let DefSection(lMenuIndex As Long, lLinkIndex As Long, sName As String)
	 On Error Resume Next
	 m(lMenuIndex).Link(lLinkIndex).sDefSection = sName
End Property

Public Property Get DefSection(lMenuIndex As Long, lLinkIndex As Long) As String
	 On Error Resume Next
	 DefSection = m(lMenuIndex).Link(lLinkIndex).sDefSection
End Property


Public Property Let LinkName(lMenuIndex As Long, lLinkIndex As Long, sName As String)
	 On Error Resume Next
	 m(lMenuIndex).Link(lLinkIndex).sLinkName = sName
End Property

Public Property Get LinkName(lMenuIndex As Long, lLinkIndex As Long) As String
	 On Error Resume Next
	 LinkName = m(lMenuIndex).Link(lLinkIndex).sLinkName
End Property


Public Property Let KeyName(lMenuIndex As Long, lLinkIndex As Long, sName As String)
	 On Error Resume Next
	 m(lMenuIndex).Link(lLinkIndex).sKeyName = sName
End Property

Public Property Get KeyName(lMenuIndex As Long, lLinkIndex As Long) As String
	 On Error Resume Next
	 KeyName = m(lMenuIndex).Link(lLinkIndex).sKeyName
End Property


Public Property Let Group(lMenuIndex As Long, lLinkIndex As Long, bGroup As Boolean)
	 On Error Resume Next
	 m(lMenuIndex).Link(lLinkIndex).bGroup = bGroup
End Property

Public Property Get Group(lMenuIndex As Long, lLinkIndex As Long) As Boolean
	 On Error Resume Next
	 Group = m(lMenuIndex).Link(lLinkIndex).bGroup
End Property


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

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



'-----------------------------------------------------
' adds a new Manual menu
'-----------------------------------------------------
Public Function AddMenu(sScriptName As String) As Boolean
  On Error GoTo AddMenuError                
  
  AddMenu = False
  
  ' increment the menu counter
  lMenuCounter = lMenuCounter + 1

  ' redim arrays in order to add the new entry
  ReDim Preserve m(lMenuCounter)

  ' set the values
  m(lMenuCounter).sScriptName = sScriptName
  m(lMenuCounter).lLinkCounter = 0
  AddMenu = True
    
  Exit Function

AddMenuError:
    Exit Function
End Function


'-----------------------------------------------------
' adds a new Manual Link for a specific script
'-----------------------------------------------------
Public Function AddLink(sDefSection As String, sLinkName As String, Optional sKeyName As String = "", Optional bGroup As Boolean = False) As Boolean
  On Error GoTo AddLinkError                

  Dim lIndex As Long
  
  AddLink = False
  
  ' increment the link counter
  m(lMenuCounter).lLinkCounter = m(lMenuCounter).lLinkCounter + 1
  lIndex = m(lMenuCounter).lLinkCounter

  ' redim arrays in order to add the new entry
  ReDim Preserve m(lMenuCounter).Link(lIndex)

  ' set the values
  m(lMenuCounter).Link(lIndex).sDefSection = sDefSection
  m(lMenuCounter).Link(lIndex).sLinkName = sLinkName
  If (sKeyName = "") Then
    m(lMenuCounter).Link(lIndex).sKeyName = sLinkName
  Else
    m(lMenuCounter).Link(lIndex).sKeyName = sKeyName
  End If
  m(lMenuCounter).Link(lIndex).bGroup = bGroup

  AddLink = True
    
  Exit Function

AddLinkError:
    Exit Function
End Function

