compile failure on recently good sketches

a few days ago this sketch compiled fine.
as of last night i get error on line 104, the rror is 'revState' does not name a type.
if i comment that out, i get another error.
I feel i must be missing somehting simple.
if someone could point me in the right direction.
this is my first real project, where i wrote all the code from scratch.
i have attached to code. note there are lines commented out, i found i do not need them and they caused issues with switching the outputs.

thanks.

// arduino nano LULL transmission control. with 5 POSITION ROTARY SWITCH , common pin tied to ground, with
// other pins for R (pin8), N (pin9), 1 (pin10), 2 (pin11), 3 (pin12) gears
// automotive 12volt relay on pin 3 (output) for Neutral Inhibit
// output to control shift solenoids are on 
// pin 4, 5, 6, 7. outputs control solenoids 1, 2, 3, 4
// Diode 1N4002 across 12v+ common to solenoids and each solenoid return (and neutral inhibit relay) to TIP122 COLLECTOR
// TIP122 Emitter tied to 12v-, common ground with arduino GND

  // setup for relay output pins
  // 1K resistor between arduino Pins and TIP122 BASE
 int solenoid1Pin = 4; // for solenoid 1
 int solenoid2Pin = 5; // for solenoid 2
 int solenoid3Pin = 6; // for solenoid 3
 int solenoid4Pin = 7; // for solenoid 4

  // setup for neutral inhibit output

int neutralinhibitPin = 3; // neutral inhibit output pin

  // setup for button input

int revPin = 8; // rev switch input
int neutralPin = 9; // neutral switch input
int firstPin = 10; // first switch input
int secondPin = 11; // second switch input
int thirdPin = 12; // third switch input

  // setup for button state

int revState = 0; // variable for reading reverse switch
int neutralState = 0; // variable for reading neutral switch
int firstState = 0; // variable for reading first switch
int secondState = 0; // variable for reading the second switch
int thirdState = 0; // variable for reading the third switch






void setup() {

// initialize the digital pins as an output.
  
  pinMode(solenoid1Pin, OUTPUT);  
  pinMode(solenoid2Pin, OUTPUT); 
  pinMode(solenoid3Pin, OUTPUT); 
  pinMode(solenoid4Pin, OUTPUT);
  pinMode(neutralinhibitPin, OUTPUT);

  
  pinMode(revPin, INPUT_PULLUP); // set rev switch as INPUT
  pinMode(neutralPin, INPUT_PULLUP); // set neutral switch as INPUT
  pinMode(firstPin, INPUT_PULLUP); // set first switch as INPUT
  pinMode(secondPin, INPUT_PULLUP); // set second switch as INPUT
  pinMode(thirdPin, INPUT_PULLUP); // set third switch as INPUT


  // turn off all outputs on initial start up

    digitalWrite(neutralinhibitPin, LOW);
    digitalWrite(solenoid1Pin, LOW);
    digitalWrite(solenoid2Pin, LOW);
    digitalWrite(solenoid3Pin, LOW);
    digitalWrite(solenoid4Pin, LOW);
    
}





void loop() 
 
   {                
 
  
  
  
  
  // main code is here, runs repeatedly:
  
   // NEUTRAL switch read and control solenoids section
  neutralState = digitalRead(neutralPin); // read the state of the neutral button

  if (neutralState == LOW) { //if switch is in N position state is LOW
    digitalWrite(neutralinhibitPin, HIGH); //turns on neutralinhibitPin 3, closing automotive relay contacts and allow start
    digitalWrite(solenoid3Pin, HIGH); //turns on solenoid 3
    digitalWrite(solenoid4Pin, HIGH); //turns on solenoid 4
    digitalWrite(solenoid1Pin, LOW); // turns off solenoid 1
    digitalWrite(solenoid2Pin, LOW); // turns off solenoid 2
  } 
  //else {
  //  digitalWrite(neutralinhibitPin, LOW); //turns off neutralinhibitPin 3, opening automotive relay contacts and inhibit start
  // digitalWrite(solenoid3Pin, LOW); //turns off solenoid 3
  //  digitalWrite(solenoid4Pin, LOW); //turns off solenoid 4
  }
  




    // REV switch read and control solenoids section
    revState = digitalRead(revPin); // read the state of the rev switch

  if (revState == LOW) { //if switch is in R position state is LOW
    digitalWrite(solenoid3Pin, HIGH); //turn on solenoid 3
    digitalWrite(solenoid4Pin, HIGH); //turn on solenoid 4
    digitalWrite(solenoid1Pin, HIGH); //turn on soleoid 1
    digitalWrite(solenoid2pin, LOW); // turns off solenoid 2
    digitalWrite(neutralinhibitPin, LOW); // turns off neutral pin
    //turns on solenoid 3, 4 and 1.  puts transmission in REV gear
  } 
  // else {
  //  digitalWrite(solenoid3Pin, LOW); //turn off solenoid 3
  //  digitalWrite(solenoid4Pin, LOW); //turn off solenoid 4
  //  digitalWrite(solenoid1Pin, LOW); //turn off soleoid 1
    //turns off solenoid 3, 4 and 1. takes transmission out of REV gear
  }


    // FIRST switch read and turn on solenoids section
    firstState = digitalRead(firstPin); // read the state of the first switch

    if (firstState == LOW)  {  // if switch is in 1 state is LOW
      digitalWrite(solenoid3Pin, HIGH); //turn on solenoid 3
      digitalWrite(solenoid4Pin, HIGH); //turn on solenoid 4
      digitalWrite(solenoid2Pin, HIGH); //turn on solenoid 2
      digitalWrite(solenoid1Pin, LOW); //turn off solenoid 1
      digitalWrite(neutralinhibitPin, LOW); // turn off neutral pin
      // turns on solenoid 3, 4 and 2. puts transmission in FIRST GEAR
    } 
    //else {
    //  digitalWrite(solenoid3Pin, LOW); //turn off solenoid 3
    //  digitalWrite(solenoid4Pin, LOW); //turn off solenoid 4
    //  digitalWrite(solenoid2Pin, LOW); //turn off solenoid 2
      // turns off solenoid 3, 4 and 2. takes transmission out of FIRST gear
      
    }

    // second swithc read and turn on solenoids section
    secondState = digitalRead(secondPin); // read the state of the second switch

    if (secondState == LOW)  {  // if switch is in 2 state is LOW
      digitalWrite(solenoid4Pin, HIGH); //turn on solenoid 4
      digitalWrite(solenoid2Pin, HIGH); //turn on solenoid 2
      digitalWrite(solenoid1Pin, LOW); // turn off solenoid 1
      digitalWrite(solenoid2Pin, LOW); //turn off solenoid 2
      digitalWrite(neutralinhibtPin, LOW); // turn off neutral pin
      // turns on solenoid 4 and 2. puts transmission in second gear
    } 
    //else {
    //digitalWrite(solenoid4Pin, LOW); //turn off solenoid 4
    //digitalWrite(solenoid2Pin, LOW); //turn off solenoid 2
      // turns off solenoid 4 and 2. takes transmission out of SECOND gear

    }


    //third switch read and turn on solenoids section
    thirdState = digitalRead(thirdPin); // read the state of the third switch

    if (thirdState == LOW)  {  // if switch is in 3 state is LOW
      digitalWrite(solenoid2Pin, HIGH); //turns on solenoid 2
      digitalWrite(solenoid1Pin, LOW); // turns off solenoid 1
      digitalWrite(solenoid3Pin, LOW); // turns off solenoid 3
      digitalWrite(solenoid4Pin, LOW); // turns off solenoid 4
      digitalWrite(neutralinhibitPin, LOW); // turns of neutral Pin
      // turns on solenoid 2 and puts transmission in third gear
    } 
    //else {
    //digitalWrite(solenoid2Pin, LOW);  //turns off solenoid 2
      // turns off solenoid 2, takes transmission out of THIRD gear
    }
   }

You got overzealous commenting-out code…

  //else {

Looks like you did that more than once. At least you’re consistent.

  //else {
  //  digitalWrite(neutralinhibitPin, LOW); //turns off neutralinhibitPin 3, opening automotive relay contacts and inhibit start
  // digitalWrite(solenoid3Pin, LOW); //turns off solenoid 3
  //  digitalWrite(solenoid4Pin, LOW); //turns off solenoid 4
  }

You commented out the opening bracket but not the closing bracket. The extra closing bracket ended the declaration of loop(). The only thing you can have outside a function is a declaration and they start with a keyword or a data type. Since the first thing in the next line of code is 'revState' you got an error because it is neither a keyword nor a data type ("does not name a type").

i think thats it. i will try getting rid of that last bracket and see what happens.

i commented out all that code, because i found it not needed.
after getting odd results, varying states of output.
putting a scope on the outputs i found them swinging between low and high without changing an input.
seems the lines after each else statement were giving me issues.
being my first project, i tried making as much comments to what i was trying to do as possible.

thanks for the quick response.

A very helpful troubleshooting tool is the Arduino IDE's Tools > Auto Format feature. If you do an Auto Format and then compare the resulting indentation to your intended program structure, it will quickly point you to where there is a missing or extra brace.

It's also just common courtesy to tidy up your code before posting it to the forum. You should also remove unnecessary blank lines. One or two blank lines used to break the code into logical sections is fine but large or random blank lines just make for more scrolling for the people trying to read your code.

Another useful feature of the Arduino IDE is that when you place the cursor next to one bracket, it puts a box around the matching bracket. If the cursor is next to the closing bracket and the opening bracket is off the screen then it will show the opening bracket line in a tool tip after a short delay.

pert:
A very helpful troubleshooting tool is the Arduino IDE’s Tools > Auto Format feature. If you do an Auto Format and then compare the resulting indentation to your intended program structure, it will quickly point you to where there is a missing or extra brace.

It’s also just common courtesy to tidy up your code before posting it to the forum. You should also remove unnecessary blank lines. One or two blank lines used to break the code into logical sections is fine but large or random blank lines just make for more scrolling for the people trying to read your code.

Another useful feature of the Arduino IDE is that when you place the cursor next to one bracket, it puts a box around the matching bracket. If the cursor is next to the closing bracket and the opening bracket is off the screen then it will show the opening bracket line in a tool tip after a short delay.

sorry. i left the commented out code in place, thinking it may have something to do with the problem that came up.

i spent about 4 hours reading rules here last night, so i could attempt to make my first post follow the needed rules.

thanks to members of the forum.
the code now works as intended.

I wasn't complaining about the commented code. In this case it did have something to do with your problem. However, if you don't need some code anymore then you should certainly delete it rather than commenting it out since it just clutters things up.

I've noticed that even some fairly experienced programmers have this problem of being "code pack rats". It's especially ridiculous when you're using version control, which allows you to look back through the history of the code to get anything that was removed.

Thanks for taking the time to read the rules! Very few do. Karma to you. The auto format thing is not in the rules, though I think it should be. So it's certainly understandable if you didn't know about that.