Shop OBEX P1 Docs P2 Docs Learn Events
SEROUT DEC formatter acting funny — Parallax Forums

SEROUT DEC formatter acting funny

CheechCheech Posts: 30
edited 2007-09-27 18:15 in BASIC Stamp
I'm trying to get my stamp to feed me back the numbers I give it, and it does for numbers up to and including 255, any number above that however is not fed back to me correctly.· I know 255 is the·last ASCII digit, but I don't see how that is relevant to what I thought the DEC command was supposed to do (convert decimals into ASCII bytes for each digit).· Here is my code:

' {$STAMP BS2p}
' {$PBASIC 2.5}
serData VAR Byte
Main:
· DO
··· PAUSE 3000
··· SERIN 16, 521, [noparse][[/noparse]WAIT("numb"), DEC serData]
··· SEROUT 16, 521, 50, [noparse][[/noparse]"Gotz it: ", DEC serData]
· LOOP
· END

example:I type "numb255 "· and I get "Gotz it: 255" as expected.· However, if I input "numb1337", I get "Gotz it: 57"

Whats up with that?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-09-27 18:15
    You have defined serData as a byte. A byte can only store values from 0 to 255. If you want larger values, you will have to define serData as a word which can store values from 0 to 65535 (or from -32768 to 32767 if you use the SDEC formatter).
Sign In or Register to comment.