-
ascii output problem
I have unit = v0(x) i am pulling this one byte out of eight
LCDOUT $FE,1,DEC UNIT," ", UNIT," ",BIN UNIT," ",HEX UNIT
here are four ways of showing the same var unit
dec unit shows 0 correct
unit shows || not correct
bin unit shows 0 correct
hex unit shows 0 correct
I try doing a if unit = 0 then somewhere but unit has the value of || and I can't use dec like unit = dec v0(x)
what am i doing and what do I need to do different?
-
Re: ascii output problem
it looks as if your trying to convert a byte to a string
I Dont know how to store a string as a variable, but you need to set the string variable to that byte
something like
UNIT VAR BYTE
mystring VAR ???
unit = v0(x)
mystring = unit
LCDOUT $FE,1,DEC UNIT," ", mystring," ",BIN UNIT," ",HEX UNIT
-
Re: ascii output problem
I do have this I might be trying to convert a string to a byte, or pulling a byte out of a string
X0 VAR BYTE(8)
-
Re: ascii output problem
Hi,
What kind of result do you expect?
There's only one thing that can be stored in a variable and that is numeric values. Those values can represent different things but that's totally up to us humans.
If the variable contains the value 0 the LCDOUT routine will send the character code for the letter zero - as long as you use the BIN, DEC, HEX modifiers.
If you don't use any modifier it will send the value exactly as it's stored in the variable, ie it will send 0. Look at the character map of the LCD to see what character that represents.
If you're grabbing ASCII data and putting that in the variable then you're not storing the number 0 in the variable, you're storing the number 48 which is the ASCII code for the letter 0. So if you want to compare your variable with that you need to do IF Unit = 48 or IF Unit = "0" - which is the exact same thing to the PIC.
/Henrik.