#Region Project Attributes
#ApplicationLabel: MUSTER - MinMax
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
'-------------------------------------------------------------------------------------------------------------------------
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
'-------------------------------------------------------------------------------------------------------------------------
Sub Process_Globals
Dim SQL1 As SQL
End Sub
'-------------------------------------------------------------------------------------------------------------------------
Sub Globals
Private ButtonMax As Button
Private ButtonMin As Button
Private LabelMax As Label
Private LabelMin As Label
End Sub
'-------------------------------------------------------------------------------------------------------------------------
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Panel1LayoutMinMax")
If FirstTime Then
SQL1.Initialize(File.DirDefaultExternal, "MinMax.sl3", True)
End If
Create_Table
End Sub
'-------------------------------------------------------------------------------------------------------------------------
Sub Activity_Resume
End Sub
'-------------------------------------------------------------------------------------------------------------------------
Sub Activity_Pause (UserClosed As Boolean)
End Sub
'-------------------------------------------------------------------------------------------------------------------------
Sub Create_Table
SQL1.ExecNonQuery ("DROP TABLE IF EXISTS MinMaxTable")
SQL1.ExecNonQuery ("CREATE TABLE IF NOT EXISTS MinMaxTable (Position TEXT, Numbers TEXT)") '--> Change the ColumnType "Numbers TEXT" into "Numbers FLOAT" --> CORRECT!
SQL1.ExecNonQuery ("INSERT INTO MinMaxTable VALUES ('001', '123')")
SQL1.ExecNonQuery ("INSERT INTO MinMaxTable VALUES ('002', '120')") '--> Minimum Value if ColunmType "Numbers" is TEXT --> WRONG!
SQL1.ExecNonQuery ("INSERT INTO MinMaxTable VALUES ('003', '999.9')") '--> Maximum Value if ColunmType "Numbers" is TEXT --> WRONG!
SQL1.ExecNonQuery ("INSERT INTO MinMaxTable VALUES ('004', '1234')")
SQL1.ExecNonQuery ("INSERT INTO MinMaxTable VALUES ('005', '345')")
SQL1.ExecNonQuery ("INSERT INTO MinMaxTable VALUES ('006', '678')")
SQL1.ExecNonQuery ("INSERT INTO MinMaxTable VALUES ('007', '121')")
SQL1.ExecNonQuery ("INSERT INTO MinMaxTable VALUES ('008', '99')")
SQL1.ExecNonQuery ("INSERT INTO MinMaxTable VALUES ('009', '199')")
SQL1.ExecNonQuery ("INSERT INTO MinMaxTable VALUES ('010', '299')")
SQL1.ExecNonQuery ("INSERT INTO MinMaxTable VALUES ('011', '9.9')") '-- Minimum Value if ColunmType "Numbers" is FLOAT --> CORRECT!
SQL1.ExecNonQuery ("INSERT INTO MinMaxTable VALUES ('012', '1999')") '-- Maximum Value if ColunmType "Numbers" is FLOAT --> CORRECT!
End Sub
'-------------------------------------------------------------------------------------------------------------------------
Sub ButtonMin_Click
Dim ReturnValue As Float
ReturnValue = SQL1.ExecQuerySingleResult("SELECT MIN (Numbers) AS MinValue FROM MinMaxTable")
LabelMin.Text = ReturnValue
End Sub
'-------------------------------------------------------------------------------------------------------------------------
Sub ButtonMax_Click
Dim ReturnValue As Float
ReturnValue = SQL1.ExecQuerySingleResult("SELECT MAX (Numbers) AS MaxValue FROM MinMaxTable")
LabelMax.Text = ReturnValue
End Sub
'-------------------------------------------------------------------------------------------------------------------------