Shop OBEX P1 Docs P2 Docs Learn Events
I give up.. — Parallax Forums

I give up..

Jayguy5000Jayguy5000 Posts: 139
edited 2005-05-31 23:41 in BASIC Stamp
I am trying to make a simple program that will look like such..

1 = $1
2 = $2

(and so on)

10 = $A
' the program i wrote is


counter VAR Word
one VAR Word
one = 1

FOR counter = 1 TO 20
DEBUG DEC one," ", HEX? one
one = one + 1
PAUSE 500
NEXT

' the outcome was

1 one = $1

so my question is, how can i take out the "one" so i only see 1 = $1

( the point of this program is pointless, I just want to see every number in decimal form translated to hexidecimal )

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-05-31 18:07
    Hello,

    ·· Modify the code to look like this:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    counter VAR Word
    one VAR Word
    one = 1
    FOR counter = 1 TO 20
    DEBUG DEC one,"=$", HEX one, CR
    one = one + 1
    PAUSE 500
    NEXT
    

    ·basicaly remove the question mark from the HEX formatter, and put in the equals sign and dollar sign you specified in the quotes.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2005-05-31 18:50
    And for fun you could do octal. [noparse];)[/noparse]

    Ryan
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-31 20:50
    To get the code to indicate hexidecimal, use the IHEX modifier like this:

    idx··· VAR··· Byte

    Main:
    · FOR idx = 1 TO 20
    ··· DEBUG DEC idx, "·= ", IHEX idx, CR
    ··· PAUSE 500
    · NEXT

    Note that you don't need the one = one + 1 line in the program since FOR-NEXT automatically increments the control variable, and that's what's being used for output.· And since you've set a high limit of 20 with the FOR-NEXT loop, you only need a Byte.· In my opinion variable conservation should always be practiced -- even in throw-away demos.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 5/31/2005 9:24:28 PM GMT
  • nick bernardnick bernard Posts: 329
    edited 2005-05-31 21:10
    idx var word...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Byte walks into a bar and orders a pint. Bartender asks him "What's wrong?"
    Byte says "Parity error." Bartender nods and says "Yeah, I thought you looked a bit off."
  • KenMKenM Posts: 657
    edited 2005-05-31 23:16
    Nick,

    Did you get hit in the head with a bowling ball? (rib jab)· I know that YOU know a byte goes up to 255, a word is not needed.
    nick bernard said...
    idx var word...

  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2005-05-31 23:41
    Unless that was "word" as in Vanilla Ice "word" [noparse];)[/noparse]

    Ryan
Sign In or Register to comment.