Trying to add real-time log messages to my app, so I can investigate problems if not a the PC.
The running code should pause while the message is showing and this is not as easy as I thought it
would be.
Currently I am trying this:
In a code module (called General) I have this:
This is called mainly from Main, eg:
In Main I have:
Dialog.Show is an adapted B4X dialog in a class and this is a ResumableSub. The code is a bit long
as it has many options, but it works fine and I use this in many places and the code flow will wait
for the dialog to be finished. I can post this if needed.
In this case though the code flow is not paused by the dialog and also I can't stop the dialog messages
by doing General.bLog2Msg = False. I have a feeling the problem is with the Sleep(1) in Sub RunLog2, but I can't do without that.
I tried the real-time Log messages with ToastMessageShow, but that doesn't pause the code flow either.
Any suggestions how to solve this problem?
RBS
The running code should pause while the message is showing and this is not as easy as I thought it
would be.
Currently I am trying this:
In a code module (called General) I have this:
B4X:
Public Sub RunLog(strLogText As String)
CallSub2("Main", "RunLog2", strLogText)
End Sub
This is called mainly from Main, eg:
B4X:
General.RunLog("ChangeMenuGroup, iCurrentMenuGroup: " & iCurrentMenuGroup)
In Main I have:
B4X:
Sub RunLog2(strLogText As String)
If General.bLog Then
Log(strLogText)
End If
If General.bLog2SQL Then
StoreLogMsg(strLogText)
End If
If General.bLog2Msg Then
'otherwise the previous dialog will be replaced by a new one
'need to press OK first
'------------------------------------------------------------
Do While Dialog.IsVisible
Sleep(1)
Loop
Dim rs As ResumableSub = Dialog.Show(Activity, Array As Object("OK", "Stop Msg"), _
"Log text", "", strLogText, _
-1, False, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Null, False, arrS, 0)
Wait For (rs) Complete (strResult As String)
If strResult = "Stop Msg" Then
General.bLog2Msg = False
chkLog2Msg.Checked = False
End If
End If
End Sub
Dialog.Show is an adapted B4X dialog in a class and this is a ResumableSub. The code is a bit long
as it has many options, but it works fine and I use this in many places and the code flow will wait
for the dialog to be finished. I can post this if needed.
In this case though the code flow is not paused by the dialog and also I can't stop the dialog messages
by doing General.bLog2Msg = False. I have a feeling the problem is with the Sleep(1) in Sub RunLog2, but I can't do without that.
I tried the real-time Log messages with ToastMessageShow, but that doesn't pause the code flow either.
Any suggestions how to solve this problem?
RBS