I will give a generic answer as my PICBasic skills are weak at the moment
Assume your variable x contains 1000
You can strip out digits like this from Right to left with position 0 at the right (least significant position) of the display
This will automatically stop if the value is 1..9 at 1 digit, or 11..99 at 2 digits and so on.Code:position = 0 if x > 9999 then x=9999 ' restrict to maximum you can display while x != 0 digit[position] = x Mod 10 ' keep the digit x = x div 10 ' integer divide by 10 position = position+1 ' next display position end while




Bookmarks