Android Question Replacing zero values with "-" in tables (inline code)

Arf

Active Member
Licensed User
In the case of the app I'm making, I am showing numeric results (usually in the format 1.23), but I wish to parse out zero values and instead of displaying as "0.00", I want to display them as "-".

In C I can do an inline test and substitution like this:
Results.Measurement == 0.0 ? "-" : Results.Measurement
to use a dash if the result is zero.

Is there any b4a equivalent, or should I just create a function to do it?
 

Arf

Active Member
Licensed User
I have tried to create a function, the problem I'm having is with casting.
When setting up the table with list.Add function I can add strings or values and the right thing gets displayed.
The function I created returns strings, and I get an error - java.lang.NumberFormatException: Invalid double "-" when a result is zero.
So, I guess at compile time the ability to deal with the result as either String or Double gets lost if I use my function.
 

Arf

Active Member
Licensed User
Ah, the problem was that I was still dividing the number by 100 in the .Add function, error gone and works OK now.
If there is an inline substitution test similar to the C one I would still like to know though. thanks.
 
Top