Shop OBEX P1 Docs P2 Docs Learn Events
Packing an array into a varable or string help — Parallax Forums

Packing an array into a varable or string help

grasshoppergrasshopper Posts: 438
edited 2008-10-08 18:13 in Propeller 1
I want to know how to pack and array into an variable.
 Var 
  Byte Stats
  long All_stats

pub main

  STATS[noparse][[/noparse] 0 ] := "0" '$30 OR $31  
  STATS[noparse][[/noparse] 1 ] := "-"     '$2B OR 2D
  STATS[noparse][[/noparse] 2 ] := "-"    '$2B OR 2D
  STATS[noparse][[/noparse] 3 ] := "X"       '$43 OR $53

  All_Stats := Stats[noparse][[/noparse]0] & Stats & Stats &  Stats




This is not working but I think i am close. Perhaps some bit shifting or something?

My All_stats variable should contain the string 0--X when done.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-10-08 18:10
    You have to use the bit logic operations (and - &, or - |, not - !)
    all_stats |= %0001 ' to turn bit 0 on
    all_stats &= !%0001 ' to turn bit 0 off
    if all_stats & %0001 ' to test bit 0 for on/off
    


    You could also use the bit operator (|<) to generate a single bit from a bit number so |<0 is the same as %0001 and |<1 is the same as %0010, etc.
  • grasshoppergrasshopper Posts: 438
    edited 2008-10-08 18:13
    Thanks mike.
Sign In or Register to comment.