It looks like the field you are trying to find the length in is a fixed character field, like
dmsg s 40a
If we do eval msg = 'Hello, World!' then msg does not contain "Hello, World!" - it contains "Hello world!" That is, he has a bunch of spaces to append to 40 characters. How fixed-length fields work by definition.
% trimr () can work very well with them, and even has an optional parameter to determine which characters to trim.
On the other hand, if you must use a variable length field
dmsg s 40a Varying
and then did eval msg = 'Hello, World!' that field actually contains only the characters assigned to it. In this case, there is no% trimr (); % len () will return the current field length.
source share