Shop OBEX P1 Docs P2 Docs Learn Events
decimal to string conversion — Parallax Forums

decimal to string conversion

felix0921felix0921 Posts: 2
edited 2008-01-19 17:33 in BASIC Stamp
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.





·

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-01-19 09:17
    Felix -

    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!
  • felix0921felix0921 Posts: 2
    edited 2008-01-19 17:33
    Hey Thanks a lot.. that is exactly what I am looking for. I never know the DIG existed.
Sign In or Register to comment.