check if serial-input contains string

hey, i think the following is an easy question for experienced arduino-users, but i'm failing for hours now and coulnt find any help.

i programmed a little app in processing which should communicate with the arduino via the serial port. in processing i simply write a string using

println("newrfid");

... which seems to work - i can see that also in the serial monitor in arduino. but i'm not able to read this specific part of the input-string but only can output the whole serial input.

this is my code:

   if(Serial.available() > 0){
     char letter = Serial.read();
     if(letter == 'newrfid'){
       soundInit();
     }
   }

it's compiling without any errors, but its just not working =(

i'm searching for a function which allows me to search the whole input-string for a specific part... i tried indexOf and equals without success.

any help would be appreciated

i use the following code for creating a string out of the serial.read-input

void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read(); 
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    } 
  }
}

and this is how my loop looks like

void loop(){
   readrfid();
   
   if (stringComplete) {
      Serial.println(inputString);
        if (inputString.substring(0)=="newrfid") {
          soundInit();
        }
      //clear the string:
      inputString = "";
      stringComplete = false;
    }
  
}

its not working :(

        if (inputString.substring(0)=="newrfid")

How many characters does inputString.substring(0) return ?

cant tell, because while processing is running i cant open the serial monitor in arduino, but need the processing app to write into the serial...

It wasn't that sort of question.

The answer to the question is in the code - there is no need to see anything in the serial monitor.

...R

     if(letter == 'newrfid'){

Which ONE key did you press to get that ONE letter in the single quotes?

Do you really expect a string of letters to match the one letter you read from the serial port? I didn't think so.

i'm searching for a function which allows me to search the whole input-string for a specific part... i tried indexOf and equals without success.

You might try the below comma , delimited method.

//zoomkat 9-9-10 simple delimited ',' string parse
//from serial port input (via serial monitor)
//and print result out serial port


String readString; // = String(100);

void setup() {
  Serial.begin(9600);
}

void loop() {
  while (Serial.available()) {
    delay(10);  //small delay to allow input buffer to fill
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      if (c == ',') {
        break;
      }  //breaks out of capture loop to print readstring
      readString += c;
    } //makes the string readString
  }

  if (readString.length() >0) {
    Serial.println(readString); //prints string to serial port out

    if(readString.indexOf("woohoo") >=0) {
      Serial.println("I found woohoo!"); 
    }

    readString=""; //clears variable for new input
  }
}