Shop OBEX P1 Docs P2 Docs Learn Events
Numbers.spin: Leading space always for sign; removal? — Parallax Forums

Numbers.spin: Leading space always for sign; removal?

xanatosxanatos Posts: 1,120
edited 2013-06-16 16:12 in Propeller 1
I'm working with Numbers.spin from the OBEX. It does everything great, but whether you want te number output signed, or not, it always leaves a leading space for that sign. You can hide the sign character so it just uses a space, otherwise it will display the + or - character.

I've tried removing references to the SChar (Sign Character) within the BCXToText method and it still leaves in that leading space... does anyone have any idea how I might:

1: Edit Numbers.spin so it doesn't even leave a space for the sign, or
2: Is there a version in Spin of a find & replace in a string that I could use to just pull that leading space out, or
3: Is there a way in Spin to just display the last X characters of a given string, or alternately to NOT display just the first character of said string?

There is a manual formatting function in Numbers but even that only gives you the option of displaying or not, the sign symbol, but it only hides it - it doesn't remove its holding space.

Numbers.spin attached for reference.

Thanks,

Dave

Comments

  • xanatosxanatos Posts: 1,120
    edited 2013-06-16 11:37
    OK, for now, I went with Phil Pilgrim's SimpleNumbers_plus.spin and I'm using the decn method - no leading spaces and all is well. At least I can follow the code in this one and understand what's happening! :-)

    Thanks Phil!

    Dave
  • Mike GreenMike Green Posts: 23,101
    edited 2013-06-16 14:00
    You can always bypass the sign character by adding one to the address returned by ToStr like this

    SendString( ..., Num.ToStr( value, Num#DEC)+1)
  • xanatosxanatos Posts: 1,120
    edited 2013-06-16 16:12
    That's a pretty cool thing to do... Thanks. I'm sure that'll be handy to know about - I have soooo much to learn in Spin...

    Thanks again,

    Dave
Sign In or Register to comment.