Android Question Possible String Comparison Bug

MrKim

Well-Known Member
Licensed User
Longtime User
This:
B4X:
Dim TestIP As String
TestIP = "192.168.1.1"
If TestIP > "" Then
    Return
End If
will fail:
java.lang.NumberFormatException: multiple points
This:
B4X:
Dim TestIP As String
TestIP = "192.168.1.1"
If TestIP <> "" Then
    Return
End If
Will not

Here is my full (unfininshed) routine which actually ignores the try and closes the program.
NOTE: This was all done in the Rapid debugger. Never tested release.
B4X:
Sub Button3_Click
Dim p As Phone
Dim sb As StringBuilder, TestIP As String
Dim i As Int
TestIP = "192.168.1.1"
''If TestIP <> "" Then
''    Return
''End If
Try
    TestIP = PATUtils.InputBox("Enter IP or blank ALL", "Find IP", "192.168.1.1", "")
    If  TestIP = "#%$Cancel" Then
        Return
    Else If TestIP > "" Then
          p.Shell( "ping -c 1 -i .2 -w 1 192.168.1."&i,Null,sb,Null)
          Log("192.168.1." &i)
        Return
    End If
    If Button3.Text = "Ping" Then
        Button3.Text = "Cancel"
    Else
        Button3.Text = "Ping" : Return
    End If
    sb.Initialize
    For i = 0 To 255
      p.Shell( "ping -c 1 -i .2 -w 1 192.168.1."&i,Null,sb,Null)
      Log("192.168.1." &i)
      DoEvents
      If sb.ToString.Contains("transmitted, 1 received") Then Log(sb)
        sb.Initialize
        If Button3.Text = "Ping" Then Exit
    Next
    Button3.Text = "Ping"
    Msgbox ("Done" ,"")
Catch
ToastMessageShow(LastException.Message,False)

'Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]
'        [-p pattern] [-s packetsize] [-t ttl] [-i interface OR address]
'        [-M mtu discovery hint] [-S sndbuf]
'        [ -T timestamp option ] [ -Q tos ] [hop1 ...] destination
End Try

End Sub
This actually fails and ignores the try catch and blows completely out of the program.
 
Top