Advertisement
Munt

Failed Loop

Oct 6th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.43 KB | None | 0 0
  1. void reJigFromMemory(){
  2.  
  3.   Serial.print("Eeprom read 1 :");
  4.   Serial.println(eepromReadOne);
  5.   Serial.print("EEprom read 2 :");
  6.   Serial.println(eepromReadTwo);
  7.   String tempArray[10];
  8.  
  9.   int charLength=eepromReadOne.length()+1;
  10.   char charBuff[charLength];
  11.   eepromReadOne.toCharArray(charBuff, charLength);
  12.  
  13.   //// GET MEMORY LOCATIONS
  14.   /*
  15. converts long string of numbers:
  16.    13161717171717252533
  17.    into separate strings:
  18.    13
  19.    16
  20.    17
  21.    17
  22.    17
  23.    17
  24.    17
  25.    25
  26.    25
  27.    33
  28.    
  29.    And stores them in an array.
  30.    */
  31.   for (int i = 0; i <10 ; i++){
  32.     tempArray[i]+=charBuff[i*2];
  33.     tempArray[i]+=charBuff[(i*2)+1];
  34.     Serial.print("I just translated :");
  35.     Serial.println(tempArray[i]);
  36.   }
  37.   /// GET THE STRINGS USING THE ABOVE ARRAYS
  38.   /*
  39. converts long list of data ie:
  40.    |0|Bingo#999#|1|Retest2#9222#|2|Retest3#92299#|3|Retest4#99339#|4|Retest5#95599#|5|Retest6#96699#|6|Retest7#99119#|7|User Defined eighth#0#|8|User Defined ninth #0#|9|User Defined tenth (last) .#0#
  41.    
  42.    into individual array strings:
  43.    
  44.    From Number = :0
  45.    To number : 13
  46.    Record 0 :          |0|Bingo#999#
  47.    From Number = :13
  48.    To number : 29
  49.    Record 1 :          |1|Retest2#9222#
  50.    From Number = :29
  51.    To number : 46
  52.    Record 2 :          |2|Retest3#92299#
  53.    From Number = :46
  54.    To number : 63
  55.    Record 3:           |3|Retest4#99339#
  56.    From Number = :63
  57.    To number : 80
  58.    Record 4:           |4|Retest5#95599#
  59.    From Number = :80
  60.    To number : 97
  61.    Record 5:           |5|Retest6#96699#
  62.    From Number = :97
  63.    To number : 114
  64.    Record 6 :          |6|Retest7#99119#
  65.    From Number = :114
  66.    To number : 139
  67.    Record 7 :               <<<<<< THIS ONE IS MISSING ? WHY?
  68.    From Number = :139
  69.    To number : 164
  70.    Record 8 :               <<<<<< THIS ONE IS MISSING ? WHY?
  71.    From Number = :164
  72.    To number : 197
  73.    Record 9 :               <<<<<< THIS ONE IS MISSING ? WHY?
  74.    
  75.    */
  76.   String tempArray2[10];
  77.   int fromLocation = 0;
  78.   int toLocation=0;
  79.  
  80.   for (int i = 0; i <10 ; i++){
  81.  
  82.     toLocation += tempArray[i].toInt();
  83.  
  84.     fromLocation += tempArray[i-1].toInt();
  85.     tempArray2[i]=eepromReadTwo.substring(fromLocation,toLocation);
  86.     Serial.print("From Number = :");
  87.     Serial.println(fromLocation);
  88.     Serial.print("To number : ");
  89.     Serial.println(toLocation);
  90.     Serial.print("I just translated :");
  91.     Serial.println(tempArray2[i]);
  92.  
  93.  
  94.   }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement