lastIndexOf is not getting recoganized on compiler

HIi,

I am stuck in a particular line. dont know where i am wrong :frowning:
command stringOne.lastIndexOf is not getting reorganized on compiler.
I am not sure why lastIndecOf is not showing up in orange in this line if (stringOne.lastIndexOf'Sr' > 0)

i have tried latest compiler, please let me know what else i can do.

#include <Stepper.h>
#include "Arduino.h"
#include "string.h"


// change this to the number of steps on your motor
#define STEPS stp
String stringOne ="";
int stp,hz,step1,step2,step3,val,spd;
int hh = 10;
int mm = 10;
int ss = 0;
int deg = 11;
int mint = 11;
int sec = 11;
int HH=0;
int SS1=0;
int SS2= 0;
int SS3 = 0;
int MM=0;

//long deg = 11;
//long mint = 11;
//long sec = 11;

Stepper stepper(STEPS, 8, 9, 10, 11);

int previous = 0;

void setup()
{
   stepper.setSpeed(spd);
  Serial.begin(9600);
}


void loop()
{
  if (Serial.available())
  { 
    while (Serial.available()>0){
      char a=Serial.read();
      stringOne = String(a) + stringOne;
      delay(10);
    }
  }

  {
    if (stringOne =="#:GR#")
    {
      hh = HH + hh;
      mm = MM + mm;
      ss = SS1 + ss;
      Serial.print (hh);
      Serial.print (':');
      Serial.print (mm);
      Serial.print (':');
      Serial.print (ss);
      Serial.print ('#');
      stringOne ="";
         }
    if (stringOne =="#:GD#"){
      
      Serial.print ('+');
      Serial.print (deg);
      Serial.print ('*');
      Serial.print (mint);
      //Serial.print (':');
      //Serial.print (sec);
      Serial.write ('#');
      //Serial.flush();
      stringOne ="";  
    }
  }
  
  if (stringOne.lastIndexOf'Sr' > 0)
  {
    HH *= 3600;
    MM *= 60;
    SS2 = SS;
    SS1 += SS2;
    val = HH+MM+SS1 ;

    stepper.step(val - previous);
    stp = val/2.3; 
    stringOne =""; 
  }


  if (stringOne == "#:STTT.T#")
  {
    Serial.print("0.005");
  }
  if (stringOne =="#:T+")
  {
    hz += .1;
    spd = hz*60;
  }
  if (stringOne =="#:T-")
  { 
    hz -= .1;
    spd = hz*60;
  }
}

error:
hnt3.ino: In function 'void loop()':
hnt3:82: error: expected `)' before '\x5372'
hnt3:82: error: could not convert 'stringOne.String::lastIndexOf' to 'bool'

thank you,
Madan

stringOne.lastIndexOf'Sr'

don't you need some () in there? and double quotes?

stringOne.lastIndexof('S')

And 'Sr' is not a character, try "Sr", but I don't know if it will work on Arduino.

panchatham:
I am not sure why lastIndecOf is not showing up in orange in this line if (stringOne.lastIndexOf'Sr' > 0)

I'm not sure why you have any trouble spotting the problem in that code - you seem to have invented a new syntax for calling a function.

@Keith, Peter

thank you so much. it worked. i am very new to coding.
im sorry for those silly errors.

madan

It looks like you are trying to write Java there.