Android Question Timing issue in Debug mode?

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Have the following code, which shows the state of all databases in the app.
As this is displayed in a SQL edittext I don't want it to be formatted as SQL as that will make no sense.
This is done with the line:
cMP.cSQLEdit.bNoEDTFormatting = True

B4X:
Sub ShowDatabasesStates
    
    Dim i As Int
    Dim strText As String
    Dim iDBCount As Int
    Dim bExtraDB As Boolean
    
    'this doesn't prevent SQL formatting when in debug mode, fine when in release mode
    cMP.cSQLEdit.bNoEDTFormatting = True
    
    bExtraDB = cMP.cConn.strExtraDB.Length > 0
    
    If bExtraDB Then
        iDBCount = 5
    Else
        iDBCount = 4
    End If
    
    Dim arrDBState(iDBCount) As Int

    For i = 0 To iDBCount - 1
        arrDBState(i) = 1
    Next
    
    Select Case miDataBase
        Case eDataBase.Main
            arrDBState(0) = 0
        Case eDataBase.NON_CLINICAL
            arrDBState(1) = 0
        Case eDataBase.KVS
            arrDBState(2) = 0
        Case eDataBase.MapnikOSM2
            arrDBState(3) = 0
        Case eDataBase.NewDB
            arrDBState(4) = 0
    End Select
    
    Select Case miAttachedDataBase
        Case eDataBase.Main
            arrDBState(0) = 2
        Case eDataBase.NON_CLINICAL
            arrDBState(1) = 2
        Case eDataBase.KVS
            arrDBState(2) = 2
        Case eDataBase.MapnikOSM2
            arrDBState(3) = 2
        Case eDataBase.NewDB
            arrDBState(4) = 2
    End Select
    
    If iDBCount = 5 Then
        strText = "seq name            file" & CRLF & _
            "----------------------------------------------------------" & CRLF & _
            arrDBState(0) & "      Main             " & "/PhonePatsE.db" & CRLF & _
            arrDBState(1) & "      non-clinical " & "/NON_CLINICAL.db" & CRLF & _
            arrDBState(2) & "      kvs               " & "/DataStorage" & CRLF & _
            arrDBState(3) & "      tiles             " & "/tiles.db3" & CRLF & _
            arrDBState(4) & "      Extra            " & "/" & cMP.cConn.strExtraDB & CRLF & CRLF & _
            "0 means main DB, 1 means DB not in use, 2 means attached DB." & CRLF & _
            "All databases will be in File.DirInternal, which is:" & CRLF & _
            File.DirInternal
    Else
        strText = "seq name            file" & CRLF & _
            "----------------------------------------------------------" & CRLF & _
            arrDBState(0) & "      Main             " & "/PhonePatsE.db" & CRLF & _
            arrDBState(1) & "      non-clinical " & "/NON_CLINICAL.db" & CRLF & _
            arrDBState(2) & "      kvs               " & "/DataStorage" & CRLF & _
            arrDBState(3) & "      tiles             " & "/tiles.db3" & CRLF & CRLF & _
            "0 means main DB, 1 means DB not in use, 2 means attached DB." & CRLF & _
            "All databases will be in File.DirInternal, which is:" & CRLF & _
            File.DirInternal
    End If
    
    cMP.cSQLEdit.edtSQL.Text = strText
    cMP.cSQLEdit.btnLargeEdit_Click
    cMP.cSQLEdit.bNoEDTFormatting = False
            
End Sub

In Debug mode this won't work, so the text is formatted as SQL. In Release mode it all works fine, so no SQL formatting takes place.
I just wonder why this is and if there is something I could do to make it work OK in Debug mode.

RBS
 

Cableguy

Expert
Licensed User
Longtime User
You can use the #if debug tag to make the compiler format it differently than it does, ie by adding escape chars... just dont forget the #end if
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
You can use the #if debug tag to make the compiler format it differently than it does, ie by adding escape chars... just dont forget the #end if
Thanks, that works indeed:

B4X:
    #if debug
    cMP.cSQLEdit.bNoEDTFormatting = True
    #end if

Rest of the code is just the same.
How does this work, so in what way is it compiled differently?

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
If I understand your code correctly, this field is read in:
cMP.cSQLEdit.btnLargeEdit_Click

Can you post the relevant code?
cMP.cSQLEdit.bNoEDTFormatting is in the posted code, so in Sub ShowDatabasesStates.

Leaving the line:
cMP.cSQLEdit.btnLargeEdit_Click
out, makes no difference, it doesn't trigger the SQL formatting.

cMP.cSQLEdit.btnLargeEdit_Click will run this code:

B4X:
Sub ShowSQLEditOnly
    
    'not sure why this + 9dip is needed to hide dark line at the bottom
    '------------------------------------------------------------------
    edtSQL.Height = (pnlSQLEditor.Height - edtSQL.Top) + 9dip
    edtSQL.Visible = True
    lblSQLResult.Visible = False
    tblSQLResult.Visible = False
    
    iSQLPanelType = Enums.eSQLPanelType.iSQLOnly
    
End Sub

RBS
 
Upvote 0
Top