Bug? B4J 5.50 SmartString with If Then on one line

mindful

Active Member
Licensed User
The below code produces error: 'Object reference not set to an instance of an object' in B4J 5.5
B4X:
Public Sub NavigateToPage(WebSocketObject As WebSocket, PageId As String, TargetUrl As String)
    If Version.Length > 0 Then TargetUrl = $"${TargetUrl}?${Version}"$     ' <-- This line produces the error
    If PageId.Length > 0 Then ABM.RemoveMeFromCache(CachedPages, PageId)
    If WebSocketObject.Open Then
        If Settings.BrowserKeepsNavigationHistory Then
            ' it keeps the navigation history in the browser
            WebSocketObject.Eval("window.location = arguments[0]", Array As Object(TargetUrl))
        Else
            ' it doesn't keep navigation history in the browser (the back button exists the application)
            WebSocketObject.Eval("window.location.replace(arguments[0])", Array As Object(TargetUrl)) 
        End If
        WebSocketObject.Flush
    End If
End Sub

If I modify the line into:
B4X:
    If Version.Length > 0 Then 
        TargetUrl = $"${TargetUrl}?${Version}"$
    End If
There is no error.
 

Cableguy

Expert
Licensed User
Longtime User
was about to report the same... You should also add a few Tags to the post, so that it can be found, as that code line refers to ABMaterial
 
Top