PDA

View Full Version : HOW TO: ASCII to Text



Rlondo
04-13-2007, 05:56 AM
I have an array in ascii:
array(4)

I know that if I want to print the 2nd item in decimal format I go:
DEBUG DEC array(1), CR

But what if I want to print it in text format?

Thanks

Zoot
04-13-2007, 06:14 AM
By default, DEBUG *is* presuming ASCII bytes, so if your array contains ASCII bytes then:




array VAR Byte(4)
idx VAR Nib

array(0) = "X"
array(1) = "Y"
array(2) = "Z"
array(3) = "!"

FOR idx = 0 TO 3
DEBUG array(idx) " is the ascii character number ", DEC array(idx), CR
NEXT

END


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST

Unsoundcode
04-13-2007, 06:41 AM
In addition if you want to display the whole or part of the array as an ascii character string

DEBUG STR array

a zero will terminate the string. Take a look at the debug and the serial commands in the Pbasic help for formatting options.

Jeff T.

Rlondo
04-13-2007, 08:12 AM
Thanks