Bug? Debug and Release do not evaluate the same

MrKim

Well-Known Member
Licensed User
Longtime User
B4X:
Dim P As Panel   
P.Initialize("DataPoint")
P.Tag = Crsr.GetDouble("QcL_Dimension")
            If GoNoGo Then
                'Log(P.Tag & "  " & (P.Tag = -1))
                If P.Tag = -1 Then
                    P.top = MeanLine.top - Size * 1.1
                    P.Color = Colors.Black
                Else
                    P.top = MeanLine.top + Size * 1.1
                    P.Color = Colors.Red
                End If
.......

In the code above I am storing a datapoint in P.Tag. In some cases this is True/False rather than a dimension so it is storing 0 or -1.

In debug mode
P.Tag = -1
returns true.
In Release Mode it Returns False.

When I change it to
If P.Tag = -1.0 Then
it works in both

Log(P.Tag) Prints -1 in debug and -1.0 in Release.
Breaking the code in debug and HOVERING over P.Tag DISPLAYS -1.0 even though it LOGS -1.

The bigger concern of course is -1 should equal -1.0 regardless.
 

MrKim

Well-Known Member
Licensed User
Longtime User
It happens because P.Tag is an Object and it fails when the numeric value is a double instead of an int.
You should change your code to:
B4X:
Dim i As Int = p.Tag
If i = -1 Then
This way it will work in all cases.
I did that. Just wanted to let you know it works in debug, not in release.
But that brings up a question. I was assuming that it failed because P.tag is something like -.99999999 and not truly -1. Is that true or is it because they are simply different data types?
 
Top