PDA

View Full Version : I give up..



Jayguy5000
06-01-2005, 02:02 AM
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 )

Chris Savage
06-01-2005, 02:07 AM
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 (mailto:csavage@parallax.com)

Ryan Clarke
06-01-2005, 02:50 AM
And for fun you could do octal. ;)

Ryan

Jon Williams
06-01-2005, 04:50 AM
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 bernard
06-01-2005, 05:10 AM
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."

KenM
06-01-2005, 07:16 AM
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 Clarke
06-01-2005, 07:41 AM
Unless that was "word" as in Vanilla Ice "word" ;)

Ryan