' Gambas module file

Public Sub CheckNameWith(sName As String, sMsg As String, Optional sMore As String)
  
  Dim I As Integer
  Dim sCar As String
  
  If Not sName Then Error.Raise("Void " & sMsg & " name")
  
  For I = 1 To Len(sName)
    sCar = Mid$(sName, I, 1)
    If IsLetter(sCar) Or If IsDigit(sCar) Or If sCar = "_" Then Continue
    If sMore And If InStr(sMore, sCar) Then Continue
    Error.Raise("Bad " & sMsg & " name: " & sName)
  Next
  
End

Public Sub Driver(hObject As Object) As _DatabaseDriver
  
  Dim hConn As Connection = Object.Parent(hObject)
  
  If Not hConn.Opened Then Error.Raise("Connection is not opened")
  Return hConn._Driver
  
End

Public Sub Main()

  Dim hMap As New DeleteMap
  Dim I As Integer
  Dim P As Integer
  
  For I = 1 To 20
    P = Rand(0, 9)
    Print "Delete "; P
    hMap.Add(P)
    Print "5 -> "; hMap.FromReal(5);; "->";; hMap.ToReal(hMap.FromReal(5))
    'hMap.Dump()
  Next

End
