You need to be clearer about what you want. ASCII is a coding for characters. That means that the binary (numeric) values stored in memory correspond to displayed characters. If you have 97 in a location in memory, it will be displayed as "a". If you have an ASCII keyboard, the key marked "a" will be represented in the computer as 97. Do you mean that you want the contents of a location in memory to be displayed as a string of digits giving the value of the location in decimal? If you're using a Stamp I/O statement like DEBUG, SEROUT or LCDOUT, the "formatter"s will do that for you. Read the Manual's description of DEC or HEX or BIN for details, but "DEBUG DEC X" will output the contents of X as a string of digits to the debug window.
That is, it's already 97.· No conversion needed.· The decimal number 97, and the character "a", are just different names for the same arrangement of ones and zeros in an eight-bit byte.
Before someone jumps on me for saying "eight-bit byte", I'll defensively point out that in the history of computing there have been bytes of other lengths than the now-standard 8 bits.
Well, here it is. I am typing in the letter a in the and storing it in a variable with the debugin command. I want to work with the letter, but I don't know how. How would I go about doing that.
like I want to write "If variable = 'a'" or something like that
Comments
A = "a"
debug dec A·· ' This will display the number 97
That is, it's already 97.· No conversion needed.· The decimal number 97, and the character "a", are just different names for the same arrangement of ones and zeros in an eight-bit byte.
Before someone jumps on me for saying "eight-bit byte", I'll defensively point out that in the history of computing there have been bytes of other lengths than the now-standard 8 bits.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net
like I want to write "If variable = 'a'" or something like that
Also you should keep in mind that when you're comparing things, upper-case "A" is not the same as lower-case "a".
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net
Post Edited (Carl Hayes) : 11/27/2008 11:14:20 PM GMT
If I understand correctly, you want to use a IF...THEN command for a variable. correct?
If so, it should look something like the following:
IF variable = "a" THEN
some set of commands, or assignments
ENDIF
Good examples of how to use this command can be found in our educational text What's A Microcontroller and also the BASIC Stamp Syntax & Reference Manual; both of which can be downloaded for free
I hope this helps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Joshua Donelson
www.parallax.com