pTAL Conversion Guide

TAL Standard Routines
pTAL Conversion Guide527302-002
17-8
$LEN
$LEN
$LEN is a TAL routine for which pTAL has a built-in routine with the same name but
slightly different behavior.
$LEN returns the length, in bytes, of a variable.
identifier
is the identifier of a simple variable, array element, pointer, structure, or structure
data item.
TAL
The TAL compiler adds a filler byte at the end of some structures to round the length of
the structure up to an even number of bytes. In some cases, however, the TAL
compiler does not include the filler byte when it calculates the value it returns to the
caller of $LEN.
TAL does not return an error for the following cases:
$LEN function applied to a structure whose last item is an UNSIGNED field
$LEN applied to a referral substructure problem.
pTAL
The native compiler reports an error if you apply the $LEN routine to a structure that
consists of an odd number of bytes, exclusive of a pad byte. You can avoid this error
by using one of the following solutions:
Declare explicitly a one-byte filler item at the end of structures that consist of an
odd number of bytes.
Use $BITLENGTH instead of $LEN.
The native compiler reports an error if you apply $LEN to an UNSIGNED variable or
structure field. Use $BITLENGTH to obtain the length of an UNSIGNED variable or
structure.
variable( )
VST096.vsd
$LEN