+ Reply to Thread
Results 1 to 3 of 3

Thread: Packing an array into a varable or string help

  1. #1

    Default Packing an array into a varable or string help

    I want to know how to pack and array into an variable.
    Code:
     Var 
      Byte Stats
      long All_stats
    
    pub main
    
      STATS[ 0 ] := "0" '$30 OR $31  
      STATS[ 1 ] := "-"     '$2B OR 2D
      STATS[ 2 ] := "-"    '$2B OR 2D
      STATS[ 3 ] := "X"       '$43 OR $53
    
      All_Stats := Stats[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.
    Last edited by ForumTools; 10-02-2010 at 04:20 AM. Reason: Forum Migration

  2. #2

    Default

    You have to use the bit logic operations (and - &, or - |, not - !)
    Code:
    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.
    Last edited by ForumTools; 10-02-2010 at 04:20 AM. Reason: Forum Migration

  3. #3

    Default

    Thanks mike.
    Last edited by ForumTools; 10-02-2010 at 04:20 AM. Reason: Forum Migration

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts