You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to build a feature in the .ksy file to reference data from a later data set to satisfy an earlier condition. In the example I included below, it will produce a value of null for the x and y fields. The reason is that the condition value is null since the z field comes after the x and y fields. Is there a method that would allow me to bypass this issue?
The reason is that the condition value is null since the z field comes after the x and y fields.
Yes. Probably in the future the compiler will be able to catch this erroneous situation and provide an error (#469), but we're not there yet.
Is there a method that would allow me to bypass this issue?
That's what instances are for. In the example you provided, it's a bit complicated by the fact that the z field that you want to use in the condition is a bit-sized integer type (https://doc.kaitai.io/user_guide.html#_bit_sized_integers), which is effectively not supported in instances yet (the problem is that there is no support for bit seeking, so the parsing of the bit type when the instance is invoked would permanently change the bit position of the stream and the seq parsing would be affected by that - #564 is related).
But you can for example read the whole byte and extract the bit you want:
Alternatively, you can always read the 2 bits the same way, and then use value instances to analyze it further (and note that in your case there's actually no need for the z_kind enum, because the 1-bit type: b1 type in Kaitai Struct is automatically translated to a boolean, see User Guide: "Booleans (...) also can be derived by using type: b1. This method parses a single bit from a stream and represents it as a boolean value: 0 becomes false, 1 becomes true."):
I want to build a feature in the .ksy file to reference data from a later data set to satisfy an earlier condition. In the example I included below, it will produce a value of null for the x and y fields. The reason is that the condition value is null since the z field comes after the x and y fields. Is there a method that would allow me to bypass this issue?
The text was updated successfully, but these errors were encountered: