Basic4android v2.00 BETA is now available. This upgrade is probably the most significant upgrade since v1.00.
Basic4android v2.00 BETA is now available. This upgrade is probably the most significant upgrade since v1.00.
Existing beta testers should soon receive an email with download instructions.
You are more than welcome to join the beta testers. Any user who is eligible for free upgrades (two years for the enterprise version and two months for the standard version) can send an email to erel@basic4ppc.com and join the group.
'class Test
Public Id As Int
Public Thing As String
Sub Initialize
Id = 0
Thing = ""
End Sub
Sub Initialize2(id As Int, thing As String
Initialize
Id = id
Thing = thing
End Sub
Dim t As Test
t. Initialize2 (3, "a thing")
Sub Initialize
Id = 0
Thing = ""
End Sub
Sub Initialize
Initialize2(0, "") ' or Initialize(0, "") if Polymorphic Initialize allowed
End Sub
sub CreateButton(text as string) as Button
dim myButton as Button
myButton.Initialize(text)
myButton.text = text
return myButton
end sub
dim ButtonView as CreateButton("OK") ' Button View is all ready to go and no need to Initialize
' Button Class
Private EventName as string
sub Initialize
Initialize("Button")
end sub
sub Initialize(EventPrefix as string)
EventName = EventPrefix
end sub
'Class module Shift
Sub Class_Globals
Public Id As Int
Public ShiftDate As String
Public CompanyId As Int
Public CompanyName As String
Public ShiftTypeId As Int
Public ShiftType As String
Public SortSeq As Int
Public AddingNew As Boolean
End Sub
'Initializes the object. You can add parameters to this method if needed.
'Accepts a map of values.
'An empty map tells us to Inilialize an "empty" object set to default values
Sub Initialize(mapValues As Map)
Id = 0
ShiftDate = "unknown"
CompanyId = 0
CompanyName = "unknown"
ShiftTypeId = 0
ShiftType = "unknown"
SortSeq = 0
Select mapValues.Size
Case 0
AddingNew = False
Case 1 'Is it a cursor? If so assume it's holding what we need & is positioned at the record we want
Dim obj As Object
obj = mapValues.GetValueAt(0)
If obj Is Cursor Then
Dim cur As Cursor
cur = obj
Id = cur.GetInt("Id")
ShiftDate = cur.GetString("ShiftDate")
CompanyId = cur.GetInt("CompanyId")
CompanyName = cur.GetString("CompanyName")
ShiftTypeId = cur.Getint("ShiftTypeId")
ShiftType = cur.GetString("ShiftType")
SortSeq = cur.GetInt("SortSeq")
End If
Case Else 'get values from mapValues
If mapValues.ContainsKey("Id") Then Id = mapValues.Get("Id")
If mapValues.ContainsKey("ShiftDate") Then Id = mapValues.Get("ShiftDate")
If mapValues.ContainsKey("CompanyId") Then CompanyId = mapValues.Get("CompanyId")
If mapValues.ContainsKey("CompanyName") Then CompanyName = mapValues.Get("CompanyNames")
If mapValues.ContainsKey("ShiftTypeId") Then ShiftTypeId = mapValues.Get("ShiftTypeId")
If mapValues.ContainsKey("ShiftType") Then ShiftType = mapValues.Get("ShiftType")
If mapValues.ContainsKey("SortSeq") Then SortSeq = mapValues.Get("SortSeq")
End Select
End Sub
'Save the contents of the Shift.
'Do a db Insert if AddingNew is True or Update if it is False
'Returns True if it was successful or False if there is an error
Public Sub Save As Boolean
Dim ret As Boolean : ret = False
'code to save will go here
Return ret
End Sub
Dim Shift As Shift
Dim m As Map : m.Initialize
Shift.Initialize(m) 'Create the "empty" object
or
m.Put("cursor", cur)
Shift.Initialize(m) 'populate from a cursor
or
m.Put("Id", db.NextId("Shifts"))
m.Put("ShiftDate", "20120615")
.
.
.
Shift.Initialize(m)
'Class module Shift
Sub Class_Globals
Public Id As Int
Public ShiftDate As String
Public CompanyId As Int
Public CompanyName As String
Public ShiftTypeId As Int
Public ShiftType As String
Public SortSeq As Int
Public AddingNew As Boolean
End Sub
'Initializes the object. You can add parameters to this method if needed.
'Accepts a map of values.
'An empty map tells us to Inilialize an "empty" object set to default values
Sub Initialize(mapValues As Map)
Id = 0
ShiftDate = "unknown"
CompanyId = 0
CompanyName = "unknown"
ShiftTypeId = 0
ShiftType = "unknown"
SortSeq = 0
Select mapValues.Size
Case 0
AddingNew = False
Case 1 'Is it a cursor? If so assume it's holding what we need & is positioned at the record we want
Dim obj As Object
obj = mapValues.GetValueAt(0)
If obj Is Cursor Then
Dim cur As Cursor
cur = obj
Id = cur.GetInt("Id")
ShiftDate = cur.GetString("ShiftDate")
CompanyId = cur.GetInt("CompanyId")
CompanyName = cur.GetString("CompanyName")
ShiftTypeId = cur.Getint("ShiftTypeId")
ShiftType = cur.GetString("ShiftType")
SortSeq = cur.GetInt("SortSeq")
End If
Case Else 'get values from mapValues
If mapValues.ContainsKey("Id") Then Id = mapValues.Get("Id")
If mapValues.ContainsKey("ShiftDate") Then Id = mapValues.Get("ShiftDate")
If mapValues.ContainsKey("CompanyId") Then CompanyId = mapValues.Get("CompanyId")
If mapValues.ContainsKey("CompanyName") Then CompanyName = mapValues.Get("CompanyNames")
If mapValues.ContainsKey("ShiftTypeId") Then ShiftTypeId = mapValues.Get("ShiftTypeId")
If mapValues.ContainsKey("ShiftType") Then ShiftType = mapValues.Get("ShiftType")
If mapValues.ContainsKey("SortSeq") Then SortSeq = mapValues.Get("SortSeq")
End Select
End Sub
'Save the contents of the Shift.
'Do a db Insert if AddingNew is True or Update if it is False
'Return True if successful otherwise False
Public Sub Save As Boolean
Dim s As String
Dim ret As Boolean : ret = True
If AddingNew Then
Try
s = "INSERT INTO Shifts (Id, ShiftDate, CompanyId, ShiftTypeId, SortSeq VALUES(?, ?, ?, ?, ?)"
db.mydb.ExecNonQuery2(s, Array As Object(Id, ShiftDate, CompanyId, ShiftTypeId, SortSeq))
Catch
ret = False
End Try
Else
Try
s = "UPDATE Shifts SET ShiftDate=?, CompanyId=?, ShiftTypeId=?,"
Catch
ret = False
End Try
End If
Return ret
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?