Get length of a LONG?
If I have a LONG that totals 12345, how can I get the length of the LONG which would be 5? I am trying to clear the characters after the number is display on an LCD without clearing all the spaces. Sometimes the length will be 2 numbers, sometimes it will be 5 numbers.

Comments
-Phil
PRI DecSize(value) : n repeat n++ until (value/=10) < 1(not tested)length := DecSize(myLong)
Andy
pub digits(value) case value 0..9 : return 1 10..99 : return 2 100..999 : return 3 1000..9999 : return 4 other : return 5For numbers, I like to right-justify in displayed. I have this bit of code in my serial and LCD objects:
pub rjdec(val, width, pchar) | tmpval, pad '' Print right-justified decimal value '' -- val is value to print '' -- width is width of (padded) field for value '' -- pchar is [leading] pad character (usually "0" or " ") ' 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 valueBut after the ROM table lookups, interpolations, and division, I wouldn't trust it to be accurate near the power-of-ten boundaries.
-Phil
Sometimes those digits mean something such as 000 where it would be important to know that 3 digits were entered. If this number being displayed is a keypad entry then simply count each digit as it is entered. The other thing is that I am a bit worried about is that you are so worried about clearing the number on the LCD in such a precise manner, what is the problem with clearing 5 digits all the time?
The problem of course with all out answers is that the question in couched in such a narrow context which can only mean a narrow answer, which might just miss the mark.