You are here: Tips and Tricks > Error Correcting in GROUP REPEAT Constructions

Error Correcting in GROUP REPEAT Constructions

Sometimes with a repeating group, you know what the size of a single iteration is because there is a length embedded in the data. The data that follows could be of a number of types, including some types that you may not be aware of when you write the decoder. It would be nice to be sure that the decoder does not get misaligned with the data if something unexpected happens. This can be handled in the following way:

GROUP object REPEAT SIZE (ToEndOfLayer)

{

FIELD type (Fixed 1) (FromTable obj_table object) "Type"

FIELD length (Fixed 1) (Decimal) "Length"

BRANCH (FromTable obj_table object)

FIELD move_to_next START_BIT (MoveRelativeFromField length 1) (Fixed 0) (Hex) SUPPRESS_DETAIL

}

Note the last field, that just moves the pointer to the start of the next iteration. Even if there is an error in the decode, or an error in the frame, or there is a new object type defined since the decoder was written, still each group begins at the correct place.