'code' does not name a type; did you mean 'tone'?

so im trying to make a small morse code decoder to print to LCD screen but i keep getting this error,

Error: 'code' does not name a type; did you mean 'tone'?

here is the code:

#include <LiquidCrystal.h>
#include <Arduino.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

code = Serial.readString();

String code = "";
int len = 0;
char ch;
char new_char;

const int but = 6;
const int led = 13;

unsigned long pres_len = 0, rel_time, pres_time = 0, old_time_len = 0, old_pres = 0, space = 0;
int state = 0;
int unit_delay = 250;
int min_delay = 10;

char MakeString()
{
if (pres_len < (unit_delay3) && pres_len > 50)
{
return '.'; //if button press less than 0.6sec, it is a dot
}
else if (pres_len > (unit_delay
3))
{
return '-'; //if button press more than 0.6sec, it is a dash
}
}

void Morse_decod()
{
static String morse[] = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....",
"..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-",
".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", "!"
};
int i = 0;
while (morse *!= "!") *

  • {*
    _ if (morse == code)_
    * {*
    * lcd.print(char('A' + i));*
    * lcd.print(" ");*
    * break;*
    * }*
    * i++;*
    * }*
    _ if (morse == "!")
    * {
    lcd.println("");
    lcd.println("This code is not exist!");
    lcd.print("");
    lcd.println("This code is not exist!");
    }*_

* code = "";*
}

void setup() {
* Serial.begin(9600);*
* pinMode(but, INPUT_PULLUP);
_ pinMode(led, OUTPUT);
lcd.begin(16, 2);*_

}
void loop() {
label:
* while (digitalRead(but) == HIGH) {}*
* old_pres = rel_time;
pres_time = millis();
_ digitalWrite(led, HIGH);
while (digitalRead(but) == LOW) {}_
rel_time = millis();
_ digitalWrite(led, LOW);_
pres_len = rel_time - pres_time;
space = pres_time - old_pres;
if (pres_len > min_delay)
_ {*_

* code += MakeString();*
* }*
while ((millis() - rel_time) < (unit_delay * 3))
* {*
* if (digitalRead(but) == LOW)*
* {*
* goto label;*
* }*
* }*

* Morse_decod();
_}*_

You have code outside of a function:

code = Serial.readString();

You are also using the code variable before it's declared.
Not only is this invalid, it also doesn't make sense. Move that code inside a function and the error will go away.

goto label;Uh-oh.

Hopefully you can now see why we ask you to use code tags when posting code

You need to post your code in code tags so that its not interpreted as markup. For instance
your indexes have been swallowed as meaning "change to italics".

How to post is explained in the how to post threads - please please read them!