PDA

View Full Version : Split number into variables



psmeets
- 6th January 2004, 10:44
Hi,

I am working on a 3 digit counter and want to display a number, let's say '263'. This value is stored in a variable (word).

To display the number correctly I need to split this number into three separate variables.

e.g.
2 into var1
6 into var2
3 into var3


Can anybody help me with a piece of code of with a hint?

Thanks!

Patrick

Melanie
- 6th January 2004, 15:22
Here's the piece of example code...

MyVar=263

var1 = MyVar DIG 2 (var1 contains the 2)
var2 = MyVar DIG 1 (var2 contains the 6)
var3 = MyVar DIG 0 (var3 contains the 3)

And as a bonus here's the hint - See PBP manual 4.17.7 use of DIG function.

Melanie

psmeets
- 6th January 2004, 15:54
Hmmm Shame on me, RTFM!!

Thanks anyways you helped me a lot!

Patrick

Desterline
- 7th January 2004, 05:15
Thanks Melanie,
I have a copy of the manual, and have read it repeatedly, but somehow missed this little nugget. Would have come in handy more than once in the past. Thanks for pointing it out.

-Denny