Does the DATA comand accept entries in Hexadecimal?
![LoopyByteloose](https://forums.parallax.com/uploads/userpics/025/nC57NMH1BTW54.gif)
I am debuging a program and·have read the DATA section of the manual.
Since it does not explicitly state that entiries may be in hexadecimal [noparse][[/noparse]each data item·has a $ at the beginning], I am beginning to wonder if this may be the source of my problems.
If needed, I·can convert all to decimal format, but Hex is visually easier to manage and identify.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
Since it does not explicitly state that entiries may be in hexadecimal [noparse][[/noparse]each data item·has a $ at the beginning], I am beginning to wonder if this may be the source of my problems.
If needed, I·can convert all to decimal format, but Hex is visually easier to manage and identify.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Comments
Let me start this with a couple of caveats:
If a particular PBASIC instruction or command specifies that the parameter MUST be in a particular numeric format (decimal, hex, or binary) any properly designated number representation should be fine.
All of what I say is subject to any insight that Jeff Martin (PBASIC IDE guru) might offer.
The IDE has no pre-disposed knowledge of any number format, except as noted above. Thus, it accepts numeric representations with no designator as decimal (default).
If the programmer adds a $ as a prefix, then this changes for the constant which follows. So too, if the programmer adds a % prefix, then the IDE automatically presumes a binary number. In each of these cases once the IDE is "primed" it will check that the character string presented falls within the scope of the number system expressed.
In other words, if decimal is presumed only the numeric characters 0-9 are permitted within the numeric character scan. If binary is specified, then only 0 or 1 is permitted within the numeric character scan. If hexadecimal is specified, then 0-9 and A-F (also a-f) are permitted. Programatically, within the IDE, this is easier than one might think.
I hope that gives you some insight.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
As I understand you, when the Manual's text mentions a range in decimal [noparse][[/noparse]such as 0-256], the IDE will accept the $prefixed in hex or the %prefixed value in binary. After all, everything must eventually be converted by the IDE and written to the EEPROM in binary.
I do understand that it is very difficult to write a document that really helps begineers which doesn't find itself full of repetition of fundamental rules--some things must be implied. The DATA command section merely discusses decimal and Ascii formats, but there are many situations that entering a big list of DATA, it is easier to read and verify hex or binary entires.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
I can't argue with what you said except for the following. You said:
"As I understand you, when the Manual's text mentions a range in decimal [noparse][[/noparse]such as 0-256], the IDE will accept the $prefixed in hex or the %prefixed value in binary. After all, everything must eventually be converted by the IDE and written to the EEPROM in binary."
Specifically, this part:
"a range in decimal [noparse][[/noparse]such as 0-256], the IDE will accept the $prefixed in hex or the %prefixed value in binary"
I MUST add, "unless it specifies that a given constant be specified in a given format (decimal, hex, binary). I just can't make as broad a statement as you have, since I can envision conditions where a given format MAY be needed. I'm NOT saying that is TRUE, just that it could or MIGHT be true. If you want to give Jeff a "head-scratcher" this may be it, since I DO have a circumstance in mind
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
The DATA can be in any of the Stamp numeric formats. If you want words, be sure to include that with every entry:
DATA 'abcde', $13,$10,0
DATA %10001000,%10000100,%010
DATA WORD 4475, WORD 7544, WORD 0, WORD $4577, WORD %1100011100010
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
The format you want have to be defined after you read the character.
I am right or wrong?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I just have been thinking too hard.
As usual, the problem and the preception of the problem are two different things.
I seem to have my SO and SI wires reversed. That is why my data was being rejected and why my verify was all zeros!
This feature really helps me program.
I use binary for DATA like blinking lights or stepper motor sequences as it helps me visualize.
I use hex for DATA that are forms of address, operational or machine code.
And I use the DATA in quotes for literal ASCII.
About the only thing I might use decimal for is plain old numbers.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com