Parsing sms messages from sm5100b cellular shield

So I figured out mostly what I needed to, should anyone find this post looking for to solve a similar problem, or stuck with the cellular shield, I documented my progress here http://www.mrphilipgordon.com/blog/tag/cellular-shield/

Or if you're too lazy to read through that, here's is a sketch that should work that you can do with what you will!

* Cellular shield code, by Phil Gordon http://mrphilipgordon.com
 This code assumes a pull down pushbutton switch attached to pin 9.
 
 Code expects text in the format x,number1,number2 with number1 being either 1 or 2.
 
 It will store number2 in a variable depending on number 1.
 
 Values of variables will be printed on press of pushbutton attached to pin 9
 
 */




#include <NewSoftSerial.h>         //Include the NewSoftSerial library to send serial commands to the cellular module.
NewSoftSerial cell(2,3);           //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.

char c = 0;                        //Will hold the incoming character from the Serial Port.
int ATReady = 0;                   //Cellular shield ready
char module1[128];                 //Value for module1
char module2[128];                 //Vue value for module2
int index;                         //Array index
long lastPress = 0;                //For debounce pushbutton
long debounceDelay = 500;          //Delay between represses              


void setup()
{
  Serial.begin(9600);              //Initialize serial ports for communication.
  cell.begin(9600);
  Serial.println("Starting SM5100B Communication...");
}

void loop() {
  if(cell.available() >0)           //If a character comes in from the cellular module...
  {
    c=cell.read();                  //Get the character from the cellular serial port.
    Serial.print(c);                //Print that character to serial monitor
    if(c == '+')                    
    {
      c=cell.read();
      Serial.print(c);
      switch(c)
      {
      case 'S':
        c=cell.read();
        Serial.print(c);
        delay(10);
        c=cell.read();
        Serial.print(c);
        delay(10);
        c=cell.read();
        Serial.print(c);
        delay(10);
        c=cell.read();
        Serial.print(c);
        delay(10);
        c=cell.read();
        Serial.print(c);
        delay(10);
        c=cell.read();
        Serial.print(c);
        switch(c)
        {
        case '3':                                  //Check for initiallisation statud, waiting for command 
          Serial.print("\n \rAlmost there...");    //  +SIND: 4
          break;
        case '4':
          Serial.print("\n \rNetwork established");
          ATReady=1;                  
          cell.println("AT+CMGF=1");               //Set message mode to text
          cell.println("AT+CNMI=3,3,0,0");         //Display messages when received
          break;
        case '7':
          Serial.print("\n \rSomething b0rked");
          ATReady=0;
          break;
        }
        break;
      case 'C':
        c=cell.read();
        Serial.print(c);
        delay(10);
        if(c == 'M')
        {
          c=cell.read();
          Serial.print(c);
          delay(10);
          if(c == 'T')
          {
            while(c != 'x')            //Wait untill the character 'x' is displayed
            {
              c=cell.read();
              Serial.print(c);
            }
            c=cell.read();
            Serial.print(c);
            delay(10);
            c=cell.read();
            Serial.print(c);
            switch(c)
            {
            case '1':                  //Run this code if number1 is a 1
              index=0;                 //Reset array index
              c=cell.read();
              Serial.print(c);
              delay(10);
              c=cell.read();
              Serial.print(c);
              while(c != '\r')         //Run loop till end of the line
              {
                module1[index] = c;    //Add character to the array
                c=cell.read();
                Serial.print(c);
                index++;               //Advance array
              }
              module1[index]='\0';     //Terminate array
              break;
            case '2':
              index=0;
              c=cell.read();
              Serial.print(c);
              delay(10);
              c=cell.read();
              Serial.print(c);
              while(c != '\r')
              {
                module2[index] = c;
                c=cell.read();
                Serial.print(c);
                index++;
              }
              module2[index]='\0';              
              break;        
            }

            break;
          } 
        }
      }
    }
  }
  if(Serial.available() >0)              //If a character is coming from the terminal to the Arduino...
  {
    c=Serial.read();                     //Get the character coming from the terminal
    cell.print(c);                       //Send the character to the cellular module.
  }

  if (digitalRead(9) == HIGH && (millis() - lastPress) > debounceDelay)   //stop button repeatedly sending commands.
  {
    lastPress = millis();
    Serial.println();
    Serial.print("Module1: ");
    Serial.println(module1);
    Serial.print("Module2: ");
    Serial.println(module2);
  }

}