Error switch quantity is not an integer

I am getting a compile error that says switch quantity is not an integer on a switch operation. The variable tested is a string and other tests using strings work okay so I am puzzled. The code is in subroutine LESSTHAN where the problem occurs. If I comment out lines 113 to 129 then there are no errors.

Error messages that I get.

Arduino: 1.8.9 (Windows 10), Board: “Arduino Nano, ATmega328P (Old Bootloader)”

C:\Users\Owner\Documents\Arduino\Pitch_Roll_test\Pitch_Roll_test.ino: In function ‘void loop()’:

Pitch_Roll_test:45:34: error: ‘QUESTION’ was not declared in this scope

if (CodeIn == ‘?’) {QUESTION();}// The first identifier is “?”

^

Pitch_Roll_test:46:31: error: ‘SLASH’ was not declared in this scope

if (CodeIn == ‘/’) {SLASH();}// The first identifier is “/” (Annunciators)

^

C:\Users\Owner\Documents\Arduino\Pitch_Roll_test\Pitch_Roll_test.ino: In function ‘void LESSTHAN()’:

Pitch_Roll_test:113:25: error: switch quantity not an integer

switch(pitchUpDn)

^

Pitch_Roll_test:117:30: error: expected primary-expression before ‘>’ token

for (pitchOld; > pitchAnglei; pitchOld --1) {

^

Pitch_Roll_test:117:56: error: expected ‘)’ before numeric constant

for (pitchOld; > pitchAnglei; pitchOld --1) {

^

Pitch_Roll_test:117:57: error: expected ‘;’ before ‘)’ token

for (pitchOld; > pitchAnglei; pitchOld --1) {

^

Pitch_Roll_test:121:30: error: expected primary-expression before ‘<’ token

for (pitchOld; < pitchAnglei; pitchOld ++1) {

^

Pitch_Roll_test:121:56: error: expected ‘)’ before numeric constant

for (pitchOld; < pitchAnglei; pitchOld ++1) {

^

Pitch_Roll_test:121:57: error: expected ‘;’ before ‘)’ token

for (pitchOld; < pitchAnglei; pitchOld ++1) {

^

Pitch_Roll_test:126:13: error: break statement not within loop or switch

break;

^

Pitch_Roll_test:127:11: error: case label ‘’+’’ not within a switch statement

case ‘+’:

^

Pitch_Roll_test:129:11: error: break statement not within loop or switch

break;

^

C:\Users\Owner\Documents\Arduino\Pitch_Roll_test\Pitch_Roll_test.ino: At global scope:

Pitch_Roll_test:134:6: error: expected declaration before ‘}’ token

}

^

exit status 1
‘QUESTION’ was not declared in this scope

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

End of error messages

The expected input to this program is of the form - <Q-nnn.n for example <Q-010.5

/* 
    Code to test pitch and roll function.
    Some elements taken from Jim's code.

*/
#include <Servo.h>

Servo Pitch;
Servo Roll;
int angle = 90;

String pitchUpDn, pitchAngle, pitchDot, pitchUnused;
int pitchOld = 90;
int rollOld = 90;
int pitchAnglei;

int CodeIn;   // used on all serial reads
/*
int KpinNo; 
int Koutpin;

String KoldpinStateSTR, KpinStateSTR, Kstringnewstate,Kstringoldstate;
String gearN,gearL,gearR,flaps;
int gearNi,gearLi,gearRi,flapsi;
*/
void setup()
{
    Serial.begin(115200);  
  Serial.println("--- Start Serial Monitor SEND_RCVE ---");
  Pitch.attach(6);
  Pitch.write(angle);
  Roll.attach(7);
  Roll.write(angle);
  pitchOld = (90);
}

void loop() {
//  {INPUTS();} //Check the Simconnect and "keys" section
  {OTHER();}// Check for "Other" things to do. (Non extraction stuff)
  if (Serial.available()) {
    CodeIn = getChar();
    if (CodeIn == '=') {EQUALS();} // The first identifier is "="
    if (CodeIn == '<') {LESSTHAN();}// The first identifier is "<"
    if (CodeIn == '?') {QUESTION();}// The first identifier is "?"
    if (CodeIn == '/') {SLASH();}// The first identifier is "/" (Annunciators)
  }

}

char getChar()// Get a character from the serial buffer
{
  while(Serial.available() == 0);// wait for data
  return((char)Serial.read());// Thanks Doug
}
void OTHER(){
/* In here you would put code that uses other data that
cant be put into an "extraction void" that references something else.
Also in here you would put code to do something that was not
relying on a current extraction trigger.
*/
}

void EQUALS(){      // The first identifier was "="
 CodeIn = getChar(); // Get the second identifier
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'C':
       //Do something
    break;
    
         //etc etc etc
     }
}

void LESSTHAN(){    // The first identifier was "<"
/*    Left here as a sample
}
CodeIn = getChar(); // Get the second identifier
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier "GearN"
      gearN = "";
      gearN += getChar();
      gearN += getChar();
      gearN += getChar();
      gearNi = gearN.toInt(); // convert it to an integer (Thanks Phill)
      if (gearNi > 99){digitalWrite(6, HIGH);}else{digitalWrite(6, LOW);}
      // See "OTHER" for more uses of gearni
    break;
*/   

CodeIn = getChar(); // Get the second identifier
  switch(CodeIn) {// Now lets find what to do with it
    case 'Q'://Found the second identifier - Pitch
      pitchUpDn  = "";   // Up is plus, down is minus
      pitchAngle = "";   // Degrees as a string
      pitchDot = "";     // Fraction indicator
      pitchUnused = "";  // Fraction part 
      pitchUpDn += getChar();
      pitchAngle += getChar();
      pitchAngle += getChar();
      pitchAngle += getChar();
      pitchDot += getChar();
      pitchUnused += getChar();    //  We will ignore the fraction for now
      pitchAnglei = pitchAngle.toInt();   // convert to an integer
        switch(pitchUpDn)
          case '-':
           if(pitchAnglei > 30) {
            pitchAnglei = 30; }
              for (pitchOld; > pitchAnglei; pitchOld --1) {
                Pitch.write (pitchOld);
                delay(20); 
              }
              for (pitchOld; < pitchAnglei; pitchOld ++1)  {
                Pitch.write (pitchOld);
                delay(20);
              }
            }
            break;
          case '+':
          
          break;  
        }

      
   
     }


void QUESTION(){    // The first identifier was "?"
CodeIn = getChar(); // Get the second identifier
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'C':
       //Do something
    break;
       
         //etc etc etc
     }
}
void SLASH(){    // The first identifier was "/" (Annunciator)
  //Do something
}

whenever you see "blah blah blah was not declaired in this scope" it could be caused by a missing or misplaced bracket. double check all your brackets

Thanks. I would delete this post if I could because I was premature in posting it.

Dale Gloer