Ok. I managed to do my work with this (after a lot of struggle) but it works. Hope this code will help somebody in the future

PS: Thanks guys for the help

Code:
ReadSerial:
   DataRec var byte[6]
   for counterB=0 to 5
       DataRec(counterB)=0
       next counterB
   
   While CounterA <= 254
        HSERIN [serdata2]
        DataRec(0)=DataRec(1)
        DataRec(1)=DataRec(2)
        DataRec(2)=DataRec(3)
        DataRec(3)=DataRec(4)
        DataRec(4)=DataRec(5)
        DataRec(5)=serdata2
        
        IF DataRec(0)=$20 AND DataRec(2)="K" AND DataRec(3) = "E" AND DataRec(4) = "Y" THEN
           ' Parse serial data (command entered)
           SerData(CounterA) = serdata2
           CounterA = CounterA + 1
        endif
   wend

   FOR COUNTERB=0 to COUNTERA
        SEROUT2 SerWRT,16416,[SerDATA(COUNTERB), 10, 13]
        NEXT COUNTERB
   Goto MainLoop