Subtracting contents of a BYTE
Oldbitcollector (Jeff)
Posts: 8,091
How do I subtract a number from a byte variable?
I've got some code that is case sensitive, so I need to decrease the contents of the byte by 32
to change case. Is there an easy way to do this instead of a lookup table?
Example if "@byte:=97" I need it to equal 65 (lower to upper)
Thanks
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.
— Calvin, of 'Calvin and Hobbes.
I've got some code that is case sensitive, so I need to decrease the contents of the byte by 32
to change case. Is there an easy way to do this instead of a lookup table?
Example if "@byte:=97" I need it to equal 65 (lower to upper)
Thanks
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.
— Calvin, of 'Calvin and Hobbes.
Comments
But to subtract from a byte variable "b" use b-=32
If you have a pointer to a byte "p", use byte[noparse][[/noparse]p]-=32
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Help to build the Propeller wiki - propeller.wikispaces.com
Prop Room Robotics - my web store for Roomba spare parts in the UK
-Phil
other variable: "variable := variable - 32" or "variable -= 32".
If what you have is an address, you'd use "byte[noparse][[/noparse] <address> ] -= 32".
You could do: "variable := ((variable > $5F) & $20) ^ variable".
It always converts lower case characters (anything from $60 to $7F)
to upper case characters (from $40 to $5F).
Working perfectly -- Thanks!
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.
— Calvin, of 'Calvin and Hobbes.