SHARE
TWEET

Everybody Edits - Read if switches are activated or not

capasha Oct 12th, 2016 (edited) 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //Inside INIT:
  3. int[] array = bytesArrayToInt(m.GetByteArray(37));
  4. for (int i = 0;i < array.Length;i++)
  5. {
  6.     Console.WriteLine(array[i]); //Writing out how many switches that is activated.
  7. }
  8.  
  9.  
  10. //Read the bytesArray from INIT
  11. private int[] bytesArrayToInt(byte[] bytesArray)
  12.     int loc5 = 0, loc2 = 0;
  13.     uint loc6 = 0, loc7 = 0, loc3 = 0;
  14.     List<int> data = new List<int>();
  15.     while (loc5 < bytesArray.Length)
  16.     {
  17.         loc6 = bytesArray[loc5];
  18.         loc7 = loc6 & 127;
  19.         loc3 = loc3 | loc7 << loc2;
  20.         if ((loc6 & 128) != 128)
  21.         {
  22.             data.Add(Convert.ToInt32(loc3));
  23.             loc3 = 0;
  24.             loc2 = 0;
  25.         }
  26.         else
  27.         {
  28.             loc2 = loc2 + 7;
  29.         }
  30.     loc5++;
  31.     }
  32.     int[] array = list.ToArray();
  33.     return intArray;
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top