Expected primary-expression before '.' token in code

While compilation erorr: expected primary-expression before '.' token

//=================Настройки=================//
const unsigned long timeClassic = 150000; //в миллисекундах
const unsigned long timeBlitz = 40000; //в миллисекундах
const unsigned long pik = 300; //в миллисекундах
//====================Код====================//
#include <Key.h> //библиотеки
#include <Keypad.h>
#include <LiquidCrystal.h>
//#include <GyverTimer.h>
#include <String.h>

const byte rs = A3, en = A5, d4 = 13, d5 = 12, d6 = 11, d7 = 10, button = 0, svet_red = A1, buzzer = A2, potenciometr = A0; //обозначаю все пины кроме кейпада

String code = "0";
int code1;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7); //пины экрана

const byte ROWS = 4; //кейпад начало
const byte COLS = 4; 
char hexaKeys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte colPins[ROWS] = {5, 4, 3, 2}; 
byte rowPins[COLS] = {9, 8, 7, 6}; 

Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); //кейпад конец

unsigned long last_time;
byte valu = 0;
boolean gameOn, codeEnter, beepBeep;
boolean mode, flag_C;
char key;
byte coursorX, coursorY;
int simbolNo, pass, pass_int;
char s1, s2, s3, s4, s5, s6, s7, s8;
String pass_str;

void setup() {
  Serial.begin(9600);
  //GTimer myTimer(MS, period);
  pinMode(potenciometr, INPUT);
  pinMode(button, INPUT_PULLUP);
  //pik = 300;
  lcd.begin(16, 2);
  code1 = String.length(code);
  for(code <= 8){
    key = customKeypad.getKey();
    lcd.setCursor(0, 0);
    lcd.print(code);
    code1 = String.length(code);
    if(key){
      code = code + key;
    }
  }
  
  //menu();
}

void loop(){
  key = customKeypad.getKey();
  if(key){
    Serial.println(key);
    lcd.print(key);
  }
}
void menu(){
  while(gameOn == 0){
    key = customKeypad.getKey();
    //char key = Keypad.waitForKey();
    if(key == '4'){
      mode = 0;
      }
    if(key == '6'){
      mode = 1;
  }
  lcd.print("      Menu");
  lcd.setCursor(0, 1);
  lcd.print("Mode:");
  //lcd.clear();
  if(mode == 0){
    lcd.setCursor(5, 1);
    lcd.print("  classic");
    //Serial.println("classic");
  }
  if(mode == 1){
    lcd.setCursor(5, 1);
    lcd.print("  blitz");
    //Serial.println("blitz");
  }
  if(key == '5'){
    if(mode == 0){
      gameOn = 1;
      lcd.clear();
      gameStartClassic();
    }
    if(mode == 1){
      gameOn = 1;
      lcd.clear();
      //gameStartBlitz();
    }
  }
  }
}

//Классический режим игры
void gameStartClassic(){
  delay(500);
  codeEnter = 1;
  while(gameOn == 1){
    while(codeEnter == 1){
    lcd.setCursor(0, 0);
    lcd.print("   Time: ");
    lcd.print(timeClassic / 1000 / 60);
    lcd.print(":");
    lcd.print(timeClassic / 1000 % 60);
    lcd.setCursor(0, 1);
    lcd.print(" Code: ");
    }
    while(beepBeep == 1){
      
    }
  }
}

//Блитз режим
void gameStartBlitz(){
  delay(500);
  codeEnter = 1;
  while(gameOn == 1){
    key = customKeypad.getKey();
    while(codeEnter == 1){
    lcd.setCursor(0, 0);
    lcd.print("   Time: ");
    lcd.print(timeBlitz / 1000 / 60);
    lcd.print(":");
    lcd.print(timeBlitz / 1000 % 60);
    lcd.setCursor(0, 1);
    lcd.print(" Code: ");
    }
    while(beepBeep == 1){
    lcd.setCursor(0, 0);
    lcd.print("   Time left: ");
    }
  }
}

Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

Welcome to the forum

  code1 = String.length(code);

You have used the wrong syntax for the length() function

ie, if you wanted to print the length of a String named wibble you would write

  String wibble = "Hello";
  Serial.println(wibble.length());

thank you, i thought this forum is slowly)

Didn't the compiler barf on that?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.