Dim LatestStatus As Int = DBUtils.GetIntFromSQL(Starter.SQL, "stops", "SELECT Count(*) AS RowNum, ifNull(status,-1) FROM stops ORDER BY id DESC LIMIT 1")
If LatestStatus = 0 Then
Log("Start")
Else
Log("Stop")
End If
'' In DBUTILS
Sub GetIntFromSQL (SQL As SQL, table As String, req As String) As Int
Dim Const NegativeRes As Int = -2147483648
Try
Dim cur As Cursor = SQL.ExecQuery(req)
cur.Position = 0
Dim rowCount As Int = cur.GetInt2(0)
If (rowCount = 0) Then
Return NegativeRes
Else
If IsNumber(cur.GetString2(1)) Then
Return cur.GetInt2(1)
Else
Return NegativeRes
End If
End If
Catch
Log("GetIntFromSQL(" & req & ").error = " & LastException.Message)
Return NegativeRes
End Try
End Sub