decimal to string conversion
I'm working on a GPS project and need to convert for example "123" into a string.· How would I go about doing that?· I am new at this and I am using a BS2
This is what I have so far
serStr· VAR···· Byte(4)
latD VAR Byte
latD = 123
serStr(4) = 0
serStr(0) =· ?? I would like to store 1 here
serStr(1) = ?? and 2 over here
serStr(2) = ?? and 3 over here
How do I go about converting the latD into individual string characters?· The numbers can vary but it is usally 2 or 3 digit numbers.
·
This is what I have so far
serStr· VAR···· Byte(4)
latD VAR Byte
latD = 123
serStr(4) = 0
serStr(0) =· ?? I would like to store 1 here
serStr(1) = ?? and 2 over here
serStr(2) = ?? and 3 over here
How do I go about converting the latD into individual string characters?· The numbers can vary but it is usally 2 or 3 digit numbers.
·
Comments
You want to use the DIG function. Here is an example taken right from the PBASIC Help File where you can learn more about it:
value·· VAR···· Word
idx····· VAR···· Nib
Main:
· value = 9742
· DEBUG ? value DIG 2········ ' Show digit 2 (7)
· FOR idx = 0 TO 4
··· DEBUG ? value DIG idx···· ' Show digits 0 - 4 of 9742
· NEXT
· END
That should get you going.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Veni, Vidi, Velcro! - I came, I saw, I stuck around!