Problem with if command and thisChar in lcd project

I changed the default lcd autoscroll code to change it to go from 1 to 12. Then I try to add an

if (thisChar == 10)
{
  lcd.clear();
}

to see if I could make the lcd screen clear.

It gives me this error code

Arduino: 1.8.3 (Windows Store 1.8.6.0) (Windows 10), Board: "Arduino/Genuino Uno"

test_1234:11: error: expected unqualified-id before 'if'

 if (thisChar == 10)

 ^

exit status 1
expected unqualified-id before 'if'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

here is my actual code

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
}

if (thisChar == 10)
{
  lcd.clear();
}


void loop() {
  // set the cursor to (0,0):
  lcd.setCursor(0, 0);
  // print from 0 to 9:
  for (int thisChar = 1; thisChar < 112; thisChar++) {
    lcd.print(thisChar);
    delay(1000);
  }

  // set the cursor to (16,1):
  lcd.setCursor(16, 1);
  // set the display to automatically scroll:
  lcd.autoscroll();
  // print from 0 to 9:
  for (int thisChar = 1; thisChar < 12; thisChar++) {
    lcd.print(thisChar);
    delay(1000);
  }
  // turn off automatic scrolling
  lcd.noAutoscroll();

  // clear screen for the next loop:
  lcd.clear();
}

Eventually I want to make hour long timer that uses a buzzer to beep after an hour. I am testing the thisChar command with lcd.clear(); to see if the buzzer could work.

can you help me with this

Your "if" is not inside any code block.

Look at your braces on setup. The line that's giving the error isn't inside of any function. Those braces are important. If you don't know what they do or how to use them then you need to check out any decent C++ tutorial.

If you look at a general C++ tutorial, it won't have setup() and loop(). The main program will be in, not surprisingly, a function called main().

aarg:
Your "if" is not inside any code block.

can you enphasize on that @aarg

Ectostream:
can you enphasize on that @aarg

Executable code like "if"s or function calls or assignments that aren't initialisations, must be inside a function