PDA

View Full Version : Formating numeric values to text



Andre_Pretorius
- 1st August 2009, 07:44
Hi there
Wonder if someone can give me advice:
I have a counter running that i use for in a RTC, i then send out the data as a serial string on my com port. the problem is that i need it to be the same length all the time.
Eg: from 0 to 9 #seck gives out 0 to 9, i need it to be 01,02, ect
from 10 onwards it is fine always 2 digits.
I use this in a few places in my program

Melanie
- 1st August 2009, 08:02
If for example...

Seconds=3
Minutes=7
Hours=4

then using the formatting string... #Hours,":",#Minutes,":",#Seconds

... would normally give you 4:7:3

but if you use... DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds

then you will get... 04:07:03

Andre_Pretorius
- 1st August 2009, 08:39
Thank you, that fixed the problem