Android Question Variable chkFilterSQL was not initialized. (warning #11)

RB Smissaert

Well-Known Member
Licensed User
Longtime User
In a B4XPages project I have a page with the following code:

B4X:
Sub Class_Globals
    Private btnSourceOfDataTypes As B4XView
    Private chkFilterSQL As CheckBox
End Sub

Sub btnSourceOfDataTypes_Click()
    
    Enums.bDataTypesFromSysColumns = Enums.bDataTypesFromSysColumns = False
    If Enums.bDataTypesFromSysColumns Then
        btnSourceOfDataTypes.Text = "From SysColumns"
    Else
        btnSourceOfDataTypes.Text = "From Cursor"
    End If
    cMP.SaveSetting("Enums.bDataTypesFromSysColumns", Enums.bDataTypesFromSysColumns)
    
End Sub

Sub chkFilterSQL_Click()
    Enums.bFilterOnLoadSQL = chkFilterSQL.Checked
    cMP.SaveSetting("Enums.bFilterOnLoadSQL", Enums.bFilterOnLoadSQL)
End Sub

chkFilterSQL and btnSourceOfDataTypes are in the layout file and the event names are the same as the view names.

I get the mentioned warning in the log and also as in the IDE (wavy line under the code and warning popping when moving cursor over it).
This happes for chkFilterSQL, but not for btnSourceOfDataTypes.
All compiles fine and runs fine.
I can't comment out:

B4X:
Private chkFilterSQL As CheckBox

As then I get a red warning in the log:
P_Settings1 - 313: Undeclared variable 'chkfiltersql' is used before it was assigned any value.
And I can't compile.

Again, all compiles and runs fine as it is, but just would like to understand and ideally fix the mentioned warning.

RBS
 

Daestrum

Expert
Licensed User
Longtime User
Could it be in the designer you haven't given it a default value?
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Could it be in the designer you haven't given it a default value?
Do you mean in the Layout visual designer?
All I can see is to tick the Checked box in the CheckBox properties.
I tried doing that, but it didn't stop the warning.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Can you upload the project?
I will try, but it is a large project.
Doing:
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=\%PROJECT_NAME%.zip
produces a file of nearly 30 Mb.
The other think to mention is that to compile successfully you will need large SQLite files, holding the data.
If the forum doesn't accept 30Mb, could I send the project to you personally?

I had mentioned this problem before and tried to reproduce in a much smaller project, but couldn't manage that.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
It will probably pop in other simpler cases as well and it will be easier to debug.

Simple workaround for misbehaving warnings: add 'ignore to that line
B4X:
Private chkFilterSQL As CheckBox 'ignore
Ok, will try again to reproduce in a much simpler project.

RBS
 
Upvote 0
Top