Shop OBEX P1 Docs P2 Docs Learn Events
grabbing the bytes out of a long — Parallax Forums

grabbing the bytes out of a long

Zap-oZap-o Posts: 452
edited 2009-04-12 15:55 in Propeller 1
I cant figure out how to grab the bytes out of a long. Certainly I am going about it in the wrong direction.
[b]

Var
   Long Junk
   Byte Parts [noparse][[/noparse] 8 ]

Main
   Junk := $36_35_34_33
  
  Parts [noparse][[/noparse] 0 ] := Junk >> 24
  Parts [noparse][[/noparse] 1 ] := Junk >> 16
  Parts [noparse][[/noparse] 2 ] := Junk >> 8
  Parts [noparse][[/noparse] 3 ] := Junk
[/b]




The idea is that Parts [noparse][[/noparse] 0 ] would be $36 and so on.

Post Edited (Zap-o) : 4/12/2009 3:55:25 PM GMT

Comments

  • Chuck RiceChuck Rice Posts: 210
    edited 2009-04-12 15:43
    Try this:

    Parts[noparse][[/noparse] 0 ] := Junk.byte[noparse][[/noparse] 0 ]
    Parts[noparse][[/noparse] 1 ] := Junk.byte[noparse][[/noparse] 1 ]
    Parts[noparse][[/noparse] 2 ] := Junk.byte[noparse][[/noparse] 2 ]
    Parts[noparse][[/noparse] 3 ] := Junk.byte[noparse][[/noparse] 3 ]
    
  • Zap-oZap-o Posts: 452
    edited 2009-04-12 15:55
    Chuck,
    You have shown me the light, now I understand "bytes and strings " more.

    Thank you.
Sign In or Register to comment.