Hi.
I've tried to add a power operator to the great B4XEval class, so that, for example, 2^3 would evaluate to 8. That's the operator the users of my app use.
Since the source was available, I added two lines to the EvalNode Sub:
But when I test it I get an exception error: java.lang.NumberFormatException: For input string: "null"
Is there any part of the code that needs changing? (or is there a way I could use the 'functions' feature supported by the library to make this work?)
Thanks a lot in advance.
I've tried to add a power operator to the great B4XEval class, so that, for example, 2^3 would evaluate to 8. That's the operator the users of my app use.
Since the source was available, I added two lines to the EvalNode Sub:
B4X:
Private Sub EvalNode (pn As ParsedNode) As Double
If pn.NodeType = NUMBER_TYPE Then Return pn.Value
Dim left As Double = EvalNode(pn.Left)
Dim right As Double = EvalNode(pn.Right)
Select pn.Operator
Case "+"
Return left + right
Case "-"
Return left - right
Case "*"
Return left * right
Case "/"
Return left / right
Case "^" 'I added this line and the next
Return Power(left, right)
Case Else
Log("Syntax error: " & pn.Operator)
Return "error"
End Select
End Sub
Is there any part of the code that needs changing? (or is there a way I could use the 'functions' feature supported by the library to make this work?)
Thanks a lot in advance.