Skip to content

Documentation bug in the example of LENGTHTO

Summary

Wrong example:

//Example number 6): with offset
type record Rec6 {
integer len,
octetstring field
}
with {
variant (len) "LENGTHTO(field) - 2"
}
// { len := 0, field := '12345678'O } would be encoded into '0212345678'O
// (1 is added to the length of `field')
// and '0212345678'O would be decoded into { len := 4, field := '12345678'O }
// (1 is subtracted from the decoded value of `len')

Possible fixes

//Example number 6): with offset
type record Rec6 {
integer len,
octetstring field
}
with {
variant (len) "LENGTHTO(field) - 2"
}
// { len := 0, field := '12345678'O } would be encoded into '0212345678'O
// (2 is subtracted from the length of `field')
// and '0212345678'O would be decoded into { len := 4, field := '12345678'O }
// (2 is added to the decoded value of `len')

Titan version

Lates

/cc @aknappqwt @mmagyari

Edited by Gábor Szalai