Bug? IF-Then is not executed when compare two Map values

Jerez

Active Member
Licensed User
Longtime User
Today my Windows 8.1 PC has installed few patches (Windows Update)

Then...

IF-Then is not executed when compare two Map values directly. (i've forced to pass to a variable)

My android.jar C:\Android-SDK\platforms\android-22\android.jar
My Javac.exe C:\Program Files (x86)\Java\jdk1.6.0_39\bin\javac.exe

B4A 5.02(1)

For example:

B4X:
Dim LocationData As Map
LocationData = ListLocations.Get(i)

.....

Dim svDevices As ScrollView = locationPanel.GetView(5)
JSON_DEVICES.Initialize(job.GetString)                              
Dim MapDevices As Map = JSON_DEVICES.NextObject
Dim m As Map = MapDevices.Get("data")
Dim ListDevices As List = m.Get("devices")
Dim lstPos As Int = 0
                           
    For j = 0 To ListDevices.Size - 1
                               
         m = ListDevices.Get(j)
                               
         If LocationData.Get("id") = m.Get("id")  Then

I need to pass the LocationData.Get("id") and m.Get("id") result to a Int variable then compare it and it work.

Before the Windows update all works ok!

why?
 

Jerez

Active Member
Licensed User
Longtime User
Thanks Erel, you are right... Windows Update(Upgraded a company software) and has been changed an API in a particular software that we use and i was comparing a string with an int! (before both values was a Int)

Any way to transform numbers to string or string to numbers in line without create a variable in each transformation?

for example:

B4X:
(Int)myStringValue

or

myStringValue.toInt32
 

Roycefer

Well-Known Member
Licensed User
Longtime User
Create a sub:
B4X:
Sub asString(s As String) As String
    Return s
End Sub
If you pass asString an Int, it will automatically be cast to a String and you'll get a String in return. If you pass it a String, it will just return the same String.
B4X:
If (asString(LocationData.Get("id"))==asString(m.Get("id"))) Then
'.....
 

Jerez

Active Member
Licensed User
Longtime User
Create a sub:
B4X:
Sub asString(s As String) As String
    Return s
End Sub
If you pass asString an Int, it will automatically be cast to a String and you'll get a String in return. If you pass it a String, it will just return the same String.
B4X:
If (asString(LocationData.Get("id"))==asString(m.Get("id"))) Then
'.....

thanks man!
 
Top