Serial Data question

I’ve lost my previous post somewhere so starting a new thread. I have written this code but it seems not to work as expected and obviously I am not understanding something. Can someone please help me understand the mistake here:

Code:

 void loop() {
         byte Dat1=0,Dat2=0,Dat3=0,Dat4=0;
              if (Serial.available() > 0  ) {
                    // read the incoming word:
                    Dat1 = Serial.read();
                    if (Dat1=='!'){
                          Dat1=Serial.read();
                          Dat2=Serial.read();
                          Dat3=Serial.read();
                          Dat4=Serial.read();
                          while (Serial.available()>0){
                              Serial.read();
                          }
                          Serial.print("I received: ");
                          Serial.println(Dat1,DEC);
                          Serial.println(Dat2+DEC);
                          Serial.println(Dat3+DEC);
                          Serial.println(Dat4+DEC);
                    }
                     if ((Dat1==Dat2) && (Dat3==Dat4)) {
                           toggle=!toggle;
                           digitalWrite(13,toggle);
                     }
                                      
//                   setValues(incomingWord);
              }
  }

The serial window shows me:

I received: 255
265
265
265

And this is the output whatever I send - I tried with !234567890 and !2222 and !23456

Serial.println(Dat2+DEC);

is the same as Dat2 + 10 (= 265)

But there are other problems, such as, reading 4 bytes when one is available.

Maybe read this: serial input basics

You test if you have at least 1 byte:
if (Serial.available() > 0 )
then proceed to read 5 bytes
// read the incoming word:
Dat1 = Serial.read(); <<1
if (Dat1==’!’){
Dat1=Serial.read(); <<<2
Dat2=Serial.read(); <<<3
Dat3=Serial.read(); <<<4
Dat4=Serial.read(); <<<5
Change your test to look for ‘!’, if received wait for 4 bytes before reading them in.

If you know how many characters you will always receive consider using Serial.readBytes with timeout as a simple way to validate your data received. Just a suggestion.

Is this your other Thread ?

...R