Int to String
Hi,
As a quick question, how would I convert an int to a string in SPIN?
For example, if I wanted to send an int to a parallax serial LCD screen, how would I convert it so that the screen understands what I am wanting to display?
Thanks,
John
As a quick question, how would I convert an int to a string in SPIN?
For example, if I wanted to send an int to a parallax serial LCD screen, how would I convert it so that the screen understands what I am wanting to display?
Thanks,
John
Comments
pub rjdec(val, width, pchar) | tmpval, pad '' Print right-justified decimal value '' -- val is value to print '' -- width is width of (space padded) field for value ' Original code by Dave Hein ' Added (with modifications) to FDS by Jon McPhalen if (val => 0) ' if positive tmpval := val ' copy value pad := width - 1 ' make room for 1 digit else if (val == negx) ' if max negative tmpval := posx ' use max positive for width else ' else tmpval := -val ' make positive pad := width - 2 ' make room for sign and 1 digit repeat while (tmpval => 10) ' adjust pad for value width > 1 pad-- tmpval /= 10 repeat pad ' print pad tx(pchar) dec(val) ' print value
Note that rjdec calls the dec method.
numbers (included in the propeller tool)
simple numbers http://obex.parallax.com/objects/182/
I really like simple numbers because it is easier to use, and has some formatting options not available in numbers (some fixed format options, for instance).
Massimo
obex.parallax.com/object/536