Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim sqlName As String = "data.db"
Dim Rmap As Map
Dim sql As SQL
End Sub
Sub createtables
sql.Initialize(File.DirDefaultExternal,sqlName,True)
sql.ExecNonQuery("Create Table rec(name Text, number text, col3 Text, col4 Text, col5 Text)")
End Sub
Sub loaddata
'Creates a map for all Alerts contacts by reading the SQL file
sql.Initialize(File.DirDefaultExternal,sqlName,False)
Dim cursor1 As Cursor
cursor1 = sql.ExecQuery("Select * from rec")
Rmap.Initialize
For i = 0 To cursor1.RowCount-1
cursor1.Position = i
Rmap.Put(cursor1.GetString("number"),cursor1.GetString("name"))
Log(cursor1.GetString("number") & " " & cursor1.GetString("name"))
Next
cursor1.Close
End Sub
Sub CountRecords As Int
Dim cursor1 As Cursor
cursor1 = sql.ExecQuery("Select * from rec")
Dim NoOfRec As Int = cursor1.rowcount
cursor1.close
Return NoOfRec
End Sub
Sub CreateMapOfNumbers As Map
Dim AllContacts As Contacts2
Dim ListOfContacts As List
Dim cons As Map
cons.Initialize()
Dim M As Map
M.Initialize()
ListOfContacts = AllContacts.GetAll(True,False)
For i = 0 To ListOfContacts.Size - 1
Dim C As Contact
C = ListOfContacts.Get(i)
Dim Nme As String = C.DisplayName
M = C.GetPhones()
'Need to find mobile number format mobile number and name
For Each k As String In M.Keys
k = k.Replace(" ","")
k = k.Replace("+44","07")
' Log("Amended " & k)
Dim str1 As String
Try
str1 = k.SubString2(0,2)
Catch
str1 = ""
Log(LastException)
End Try
If str1 = "07" Then
'07730145660,Fred
cons.Put(k,Nme)
Log(k & " " & Nme)
End If
'
Next
Next
Return cons
End Sub