Sub butOpenSQL_Clicked(Target As String)
If shl.IsInitialized Then
shl.KillProcess
End If
ShellParameters = File.Combine(others.Folder, db.DBname)
If File.Exists("", ShellParameters) = False Then
page.ShowToast("", "", "No database available: " & ShellParameters, 5000, False)
Return
End If
ProcessStatus = 1
If others.DetectOS = "linux" Then
Dim WorkingDirectory As String = File.Combine(File.DirApp, "sqlite-tools-linux-x86-3430100")
Dim binary As String = "sqlite3"
Else If others.DetectOS = "windows" Then
Dim WorkingDirectory As String = File.Combine(File.DirApp, "sqlite-tools-win32-x86-3430100")
Dim binary As String = "sqlite3.exe"
End If
binary = File.Combine(WorkingDirectory, binary)
shl.InitializeDoNotHandleQuotes("shl", binary, Array As String(ShellParameters))
shl.InputStreamEnabled = True
shl.WorkingDirectory = WorkingDirectory
ProcessStatus = 3 'working
shl.RunWithOutputEvents(-1)
Addto_Log("DB opened OK")
End Sub
Sub editSQLcommand_EnterPressed(value As String)
Log(value)
If value.Trim = "" Then Return
Dim m As ABMModalSheet = page.ModalSheet("SQLconsole_ModalSheet")
editSQLcommand = m.Footer.Component("editSQLcommand")
'send to Shell stream
If shl.IsInitialized Then
Addto_Log(value)
editSQLcommand.Text = ""
m.Footer.Refresh
Dim v As String = value & CRLF
shl.WriteToInputStream(v.GetBytes("UTF8"))
Else
page.ShowToast("", "", "Open database first", 5000, False)
End If
End Sub
Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
isError = Not(Success)
Log("shl_ProcessCompleted: " & Success & " ; exitcode = " & ExitCode)
ProcessStatus = 1
If isError Then
Log(StdErr)
Addto_Log(StdErr)
End If
End Sub
Sub shl_StdOut (Buffer() As Byte, Length As Int)
Dim s As String = BytesToString(Buffer, 0, Length, "UTF-8")
CallSubDelayed2(Me, "Addto_Log", s)
End Sub
Sub shl_StdErr (Buffer() As Byte, Length As Int)
Dim s As String = BytesToString(Buffer, 0, Length, "UTF-8")
CallSubDelayed2(Me, "Addto_Log", s)
End Sub
Sub Addto_Log(txt As String)
If txt = "" Then Return
Dim m As ABMModalSheet = page.ModalSheet("SQLconsole_ModalSheet")
logSQL = m.Content.Component("logSQL")
logSQL.Text = logSQL.Text & txt & CRLF
logSQL.Refresh
End Sub