'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim Wt As SQL
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim ItemHeight As Int
ItemHeight = 40dip
Dim svVKL As ScrollView
Dim crVKL As Cursor
Dim crCk As Cursor
Dim bOK As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
svVKL.Initialize(0)
Activity.AddView(svVKL, 0, 10, 100%x, 80%y)
If Wt.IsInitialized = False Then
Wt.Initialize(File.DirDefaultExternal, "wt.sql", False)
End If
crVKL = Wt.ExecQuery("Select Name From Table ORDER BY Name ASC")
CreateList(crVKL.RowCount)
Activity.LoadLayout("VKL")
' Activity.Title("VKL")
crVKL.Close
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub CreateList(NumberOfItems As Int)
svVKL.Panel.Height = ItemHeight * NumberOfItems
For i = 0 To crVKL.RowCount -1
Dim cb As CheckBox
cb.Initialize("")
crVKL.Position = i
cb.Text = crVKL.GetString("Name")
svVKL.Panel.AddView(cb, 0, ItemHeight * (i-0), svVKL.Width, ItemHeight -2dip)
Next
crCk = Wt.ExecQuery("Select Name From VKL")
If crCK.RowCount > 0 Then
For i = 0 To svVKL.Panel.NumberOfViews -1
Dim cb As CheckBox
cb.Initialize("")
[B]Dim pnl As Panel delete - not needed [/B]
[B]pnl.Initialize("") delete - not needed [/B]
crVKL.Position = i
For j = 0 To crCK.RowCount -1
crCK.Position = j
[B]cb.svVKL = Panel.GetView(i)'use cb as the view is a checkbox [/B]
[B]If crCK.GetString("Name") = cb.Text Then 'you can use the Text as you set it to "Name" above [/B]
cb.Checked = True
End If
Next
Next
End If
End Sub
Sub bOK_Click
Wt.ExecNonQuery("DELETE from VKL")
Wt.ExecNonQuery("REINDEX VKL")
Wt.BeginTransaction
For i = 0 To svVKL.Panel.NumberOfViews -1
Dim cb As CheckBox
cb = svVKL.Panel.GetView(i)
If cb.Checked = True Then
Wt.ExecNonQuery2("INSERT INTO VKL VALUES(NULL, ?)", Array As Object(cb.Text))
End If
Next
Wn.TransactionSuccessful
Wn.EndTransaction
End Sub
Sub bClear_Click
For i = 0 To svVKL.Panel.NumberOfViews -1
Dim cb As CheckBox
cb.Initialize("")
cb.Checked = False
Next
Wt.ExecQuery("DELETE from VKL")
Wt.ExecQuery("REINDEX VKL")
End Sub