Can the number of repetitions of a structure be set by a number from within another structure?

0 votes
asked Nov 23, 2022 in Grammars by patrickl (140 points)
Specifically, I've got a structure that's a fixed size data block, that's meant to repeat exactly the number of times specified by a number from another structure earlier in the file. There's the repeat dropdown, that seems like it might be intended for this sort of purpose, but the only option in it is "<none>", and the min and max values don't seem to have any way to fill in a variable either.

1 Answer

0 votes
answered Feb 17, 2023 by andreas (3,300 points)
You can reference a number element parsed previously by name (if it doesn't have spaces in the name).

Simply put the name of that element in the "Repeat max" field.

The "Repeat" field only works for number elements being in the same structure. The advantage of the Repeat field is that it allows to reference a field that's not yet parsed.