Show TOC

Determining the Length and DistanceLocate this document in the navigation structure

Determining the Length and Distance

The field length or the distance between two fields can be determined with the DESCRIBE FIELD and DESCRIBE DISTANCE statements. The IN BYTE/CHARACTER additions must be defined for the following variants under Unicode:

DESCRIBE FIELD f LENGTH len IN BYTE MODE.

The length of field f is determined in bytes and passed to field len.

This variant returns the length of the reference, and not the length of the contents, for all internally referenced data types (strings as well as field and object references). Only variant IN BYTE MODE is therefore allowed for such fields.

DESCRIBE FIELD f LENGTH len IN CHARACTER MODE.

The length of field f is returned here in characters if the argument has character-type only. f may not have type STRING. The relevant check is performed statically and dynamically and causes a syntax or runtime error, depending on the type.

DESCRIBE DISTANCE BETWEEN a AND b INTO x IN BYTE MODE.

This statement returns the distance between fields a and b in bytes in field x.

DESCRIBE DISTANCE BETWEEN a AND b INTO x IN CHARACTER MODE.

This statement returns the distance in characters, where the result always refers to the start of the field. Whether or not the distance between the arguments can be divided by the platform-specific length in characters and whether both fields a and b have the right alignment is only checked at runtime. Otherwise there is a runtime error.