vivoactive - format wont accept minus symbol.

Former Member
Former Member
These lines will crash the vivoactive. They don't crash my 920xt though.
dc.drawText(textX + 35, y, font, format(" $1$ ",[num.format("%-0.1f")]), just);
dc.drawText(textX + 35, y, font, format(" $1$ ",[num.format("%-d")]), just);


with the minus removed, the lines will work, but obviously do not indicate negative numbers. Edit: My bad. It will display the negative sign. I remember events as it not working, so either I am remembering it wrong, or it was fixed somewhere along the way in a firmware update.
dc.drawText(textX + 35, y, font, format(" $1$ ",[num.format("%0.1f")]), just);
dc.drawText(textX + 35, y, font, format(" $1$ ",[num.format("%d")]), just);
  • What I do to get a +/- on the va is this:

    var diffstr=diff.format("%+d");

    if diff is 100, it will show "+100", and for -100, it will show "-100"
  • Using a dash in the flags field of the format specification is supposed to cause the output to be left justified. This has no effect if you don't specify a width. See the documentation.

    If you want to display a sign all of the time (as suggested by Jim above), you'll have to use +. If you only want a sign for negative values, that should be the default (positive values display with no sign, negative values show a sign). If you want to always display a dash in front of the text, put it outside the format specification.

    Of course, using a dash in the flags field should not cause a crash, so that is a bug.

    Travis
  • Former Member
    Former Member over 9 years ago
    Resolved. See edit in first post.