Skip to main content Skip to complementary content

The SetElementProperty function

You can use the SetElementProperty function only in the Util tab of the expression. This function can be used for the Flat and Cobol representations. Although the three properties, byte offset, number of bytes, and loop count, are unavailable at once for both representations.

The Flat representation has all the three properties available. In the Cobol representation, the byte offset is unavailable.

Example: Set number of bytes with Flat representation

The SetElementProperty can be used to specify the size of an element in the number of bytes.

Consider the following the Flat structure:
This structure has three fields:
  • a: an integer with a fixed size of two

  • c: a string with a fixed size of two

  • b: a string without a fixed size

The a field gives the size of the b field. Since the size of the b field is dynamic, write an expression to compute it:

Use the SetElementProperty function to specify the size of the b field, and the value is provided by the content of the element.

Example: Set loop count and byte offset with Flat representation

The SetElementProperty can be used to specify the byte offset of an element from its enclosing element and the actual number of times an element occurs when it loops.

Consider the following Flat structure:

This structure has three fields:

  • a: a string with a fixed size of two
  • b: an array of string with elements having a fixed size of two
  • c: a string with a fixed size of two

The Document tab shows an example of sample data.

In this example, you want to keep only the first three elemets of the b array, example b1b2b3, and for the c field, skip the data, example b4b5. You want to keep only c1.

To achieve this, use the SetElementProperty function.

On the b field, specify the following Util expression with a SetElementProperty function indicating the number of occurrence of the b field. In this example, set it to three (3):
In the c field, specify an offset to skip the remaining b4b5 data:

The offset is absolute, for example, it specifies the number of bytes from the beginning of the document.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!