Code: Select all
'--- check if valid frame ---
IF RecBuf[0] = STX AND IF RecBuf[1] = &H6 AND IF (RecBuf[8] = ETX OR (RecBuf[0] + RecBuf[1] + RecBuf[2] + RecBuf[3] + RecBuf[4] + RecBuf[5] + RecBuf[6] + RecBuf[7] + RecBuf[8]) = 0) THEN

Ron, if you agree this could be integrated in the next release.
PS. As I said, I'm just starting with Gambas ... I don't quite understand why summing only positive values different from 0 would end up with 0 but ... The tests I did with gambas seems to indicate that RecBuf being defined as a Byte, it is limited to 255. That is to say if the sum ends up as 255 it will remain 255, if it ends up as 258 for example, it will be converted to 2 (&H02 + &H06 + &HFA = 258 (dec) => 2).