switch with array question

After coding a decent amount of code, pulling my hair out, walked away.. googled for the answer and with no real help other than recoding it with else if statements... I'm here to see if I missed anything...

I'm running a SainSmart uno, nothing added to it.. and a simple winform program on a dell with windows xp I'm using the usb cable, usb serial port, on the board that came with it and COM4 usb port on the computer....

I have serial communication between the board and the winform.. I can turn the made in led light with a check box event from the form.. I can send a request to the board and retrieve variables and display them in a form on the computer.....

I have tried using char arrays with no relief... String arrays aren't allowed in a switch statement.. I have added booleans and everything to try to get it working..

please remember I'm fairly new to c++.. and I have altered this code multiple times, so I might have something in there that doesn't make since lol..

int ledPin = 13;
boolean responce = false;
String message ="";
boolean sDone=false;

boolean gotName = false;
boolean gotValue = true;

int data =0;
String name[10];
String value[10];

void setup(){
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}
void loop(){
  if(responce) {
    message += '\r\n';
    Serial.println(message);
    Serial.println(name[0]);
    message ="";
    responce = false;
    gotName = false;
    gotValue = true;
    
  }
}
void serialEvent(){
  
  while (Serial.available()) {
    
    
    
    // get the new char
    char inChar = (char)Serial.read(); 
    // comma marks the end to values
    if (inChar == ','){
      //reset gotName for the next name[data]
      gotValue = true;
      gotName= false;
      data++;
      
      // = follows the end of name. now get name value..
    }else if(inChar == '='){
      gotValue = false;
      gotName= true;
      
    
    
    }else if(inChar == '\n'){
      // the new line tells us we're done reading
      
      
      
      
    
    
    }else{
      // we have found a = sign, a value should follow
      if((gotName) && (!gotValue)){
        value[data] +=inChar;
        
      }else{
        // we're still reading a name.. 
      name[data] += inChar;
      
      }
     
  }
    
  }
  
  
    for(int i=0; i <= data; i++){
      
      switch (name[i]) {
         case 'apple':    
           digitalWrite(ledPin, HIGH);
           message +="Light on";
           name[i] =0;
         break;
      default:
     // turn all the LEDs off:
       digitalWrite(ledPin, LOW);
       message += value[data];
       message +=',';
       value[i]=0;
      }// moved this to for loop to see if that's the problem
      if (i >= data){
        responce = true;
      }
    }
    
}

What I am trying to do is send serial data from the form that looks like this..

apple=sweet, pear=hard, and so on..
So, as you can tell it don't work like I had planed. I was trying to read the serial into name[0] until it finds the "=" and then read it into value[0] until it finds a comma marking the end of value.. then add one to "data" so it can start reading into name[1] and so on...

char doesn't return anything like it should... string wont work the for (i) switch so I can send multiple commands in one transmittion and send the "message" along with the return carrage to get my form to quit the ReadLine();

This is the code I know works with serial...

int ledPin = 13;
int servoLast, servoNew,servoMove;
void setup() {
 Serial.begin(9600); 
       pinMode(ledPin, OUTPUT);
     
}

void loop() {

 if (Serial.available() > 0) {
   int inByte = Serial.read();
   switch (inByte) {
   case 'a':    
     digitalWrite(ledPin, HIGH);
     Serial.write("Light on");
     Serial.write('\r\n');
     break;
   case 'b':    
     digitalWrite(ledPin, LOW);
     Serial.write("Light Off");
     Serial.write('\r\n');
     break;
     
    case '1':    
     
     Serial.write("37.061906");
     Serial.write('\r\n');
     break;
    case '2':    
     
     Serial.write("-85.119327");
     Serial.write('\r\n');
     break;
   default:
    
       digitalWrite(ledPin, LOW);
       Serial.write(inByte);
       Serial.write('\r\n');
     
   } 
 }

}

if you want the winform code, I'll have to zip it up and attach it as it's a Visual c++ 2010 project..

         case 'apple':

Single quotes are for single characters. Please post a picture of your keyboard with the apple key circled.

If you positively must (you really don't) use Strings, you can use if/else if/else statements.

You can't use strings in switch statements, either.

So you're sending "apple=sweet, pear=hard" from the serial monitor and you want the code to split it up? You can use strtok() for that. Then instead of case statements, you can use strcmp()

in the windows form.. this is part of the code I'm using.. I want to use a label with the textbox data and send multiple textboxes data at the same time.. then retrieve the message back into the form

                                this->serialPort1->PortName = "COM4";  // Replace with your COM port!
				this->serialPort1->Open();  // open port
				this->serialPort1->ReadTimeout = 500; //time out for ReadLine because it waits for return carrage
				this->serialPort1->Write(this->textBox1->Text);  // send text input to arduino
                                 // string to hold arduino responce
				String^ message= "";
				
				
				try{// try to read serial and catch the time out if it fails..
				message = this->serialPort1->ReadLine();
				}
                                 catch (TimeoutException ^) {message= "Error"; }

				this->progressBar1->Value = 50;
				this->textBox2->Text =L"data sent"; 
				this->textBox1->Text = this->textBox1->Text;
				// set textbox3 text to arduino responce
				this->textBox3->Text = message;

PaulS:

         case 'apple':

Single quotes are for single characters. Please post a picture of your keyboard with the apple key circled.

If you positively must (you really don't) use Strings, you can use if/else if/else statements.

You can't use strings in switch statements, either.

I missed the single quotes.. thanks for pointing that out..

the name[] and value[] arrays were defined as char, but I wasn't getting the data that I was expecting.. Like I have said, c++ is fairly new to me.. I guess I haven't understood everything I need to....