Shop OBEX P1 Docs P2 Docs Learn Events
Convert String to Byte Array — Parallax Forums

Convert String to Byte Array

ALIBEALIBE Posts: 299
edited 2007-02-25 16:53 in Propeller 1
I have a string that I want to convert to a byte array. I searched the forum but, could not find any posts or pointers to this.· Can someone please help shed some light.



thanks in advance



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"any small object, accidentally dropped, goes and hides behind a larger object."


ALIBE - Artificial LIfe BEing. In search of building autonoumous land robot
http://ALIBE.crosscity.com/
·

Comments

  • ALIBEALIBE Posts: 299
    edited 2007-02-25 16:40
    repeat strsize(str_addr)
    TargetByteArray[noparse][[/noparse]x] : = byte[noparse][[/noparse]str_addr++]

    · x:=·· StrSize(str)
    · iCounter:=0
    · repeat x
    ··· OutgoingData[noparse][[/noparse]iCounter++] := byte[noparse][[/noparse]str++]

    Where str is the source string and OutgoingData is the target byte array

    Sorry - never mind, I think this might work this works well.

    thanks all

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "any small object, accidentally dropped, goes and hides behind a larger object."


    ALIBE - Artificial LIfe BEing. In search of building autonoumous land robot
    http://ALIBE.crosscity.com/


    Post Edited (ALIBE) : 2/25/2007 4:49:38 PM GMT
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-02-25 16:53
    Confusion here... a string IS nothing more than a byte array.
    Byte myStr[noparse][[/noparse]10]
    .
    .
    .
    serial.tx(myStr[noparse][[/noparse]5]) ' send 6th character (zero based)
     
    

    -martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    StampPlot - GUI and Plotting, and XBee Wireless Adapters
    Southern Illinois University Carbondale, Electronic Systems Technologies

    Post Edited (Martin Hebel) : 2/25/2007 4:57:33 PM GMT

Sign In or Register to comment.