How to discard same string received at Arduino I don't want the same string to be printed again and again. I'm getting the data into an Excel sheet.

byte readValue1=0;
byte readValue2=0;
int add=0;
int row=0;
int Zigbee1=0,Zigbee2=0,Zigbee3=0;
void setup() {
    Serial.begin(9600);
        Serial.println("CLEARDATA");
        Serial.println("LABEL,Time,Zigbee,a1,a2,a3,a4,a5,a6,a7");
        row++;
}

void loop(){
  String a1,a2,a3;
  String c1,c2,c3;
  int b;

  if (Serial.available()&gt;21){
        if(Serial.read() == 0x7E) {  
            for(int i=0; i&lt;10; i++){
                byte discard = Serial.read();
            }
                        add = Serial.read();     
                       if(add == 33)
                        {                 
                        a1 = func1();                    
                        if(a1==c1){
                          b=0;
                        } 
                        else                   
                        {
                          b = a1.length(); 
                        } 
                        if(b != 0)
                       {
                        Zigbee=1;
                        Serial.print("DATA,TIME,"); Serial.print(Zigbee);                     
                        Serial.print(","); Serial.println(a1);
                        row++;              
                        }
                        }
                      else if(add == 48)
                        { 
                        a2 = func1();
                        b = a2.length();
                        if(b != 0) 
                      { 
                        Zigbee=2;
                        if(a2!=c2){
                       Serial.print("DATA,TIME,"); Serial.print(Zigbee);                     
                       Serial.print(","); Serial.println(a2);
                        }
                        c2=a2;
                       row++;                                          
                        }
                        }

                       else if(add == 69)
                        {
                          a3 = func1();
                          b = a3.length();
                          if(b != 0)
                         {
                          Zigbee=3;
                          Serial.print("DATA,TIME,"); Serial.print(Zigbee);                     
                          Serial.print(","); Serial.println(a3);
                          row++;                  
                    }
                        }
} 
}
}
Only print the string when he has changed?

String previousString = "";
String newString = "";

if(newString != previousString){
   println(newString);
   previousString = newString;
}


I'm not sure if it's applicable in your situation, just the first thing that came to my mind. You (kinda) should make a function of it, so that you don't have to copy/paste it all the time and it'll look way better.

EDIT: 

A fuction could be made like so:

String previousString = ""; //Put this above your setup code (global variables)

void NoSpamString(String input){ //Put this block before the setup
   if(input != previousString){
      println(input);
      previousString = input;
   }
}


You can then use: NoSpamString("text"); to print a line withouth spamming it.