Shop OBEX P1 Docs P2 Docs Learn Events
HOW TO: ASCII to Text — Parallax Forums

HOW TO: ASCII to Text

RlondoRlondo Posts: 6
edited 2007-04-13 01:12 in BASIC Stamp
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

Comments

  • ZootZoot Posts: 2,227
    edited 2007-04-12 23:14
    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
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-04-12 23:41
    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.
  • RlondoRlondo Posts: 6
    edited 2007-04-13 01:12
    Thanks
Sign In or Register to comment.