B4J Question [BANano] Evaluate boolean function

angel_

Well-Known Member
Licensed User
Longtime User
I try to evaluate the function but the results returned are not what I expected, what am I doing wrong?

B4X:
Sub WelcomePageButton_Click (event As BANanoEvent)
    Log(IsCheckOk("ab"))  'Return ab
    Log(IsCheckOk("cd"))  'Return ab
    Log(IsCheckOk("de"))  'Return ab
End Sub

Sub IsCheckOk(MyValue As String) As Boolean
    Dim MyCheck As Boolean = (MyValue = "ab") Or (MyValue = "cd")
   
    Return MyCheck
End Sub
 
Solution
It's a bug in the BANano parser. A workaround is separating the declaration from the assignment:

B4X:
Sub IsCheckOk(MyValue As String) As Boolean
    Dim MyCheck As Boolean
    MyCheck = (MyValue = "ab") Or (MyValue = "cd")
   
    Return MyCheck
End Sub

Alwaysbusy
Top