Link to home
Start Free TrialLog in
Avatar of mayankgangrade
mayankgangrade

asked on

Difference between %len and %size

what is the difference between %len and %size built in function with an example?
ASKER CERTIFIED SOLUTION
Avatar of daveslater
daveslater
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Member_2_276102
Member_2_276102

mayankgangrade:

%len is concerned with the value of a variable, while %size is concerned with how much memory a variable occupies. You'd use %size in order to calculate offsets in memory. You'd use %len to determine the current number of significant digits or characters.

Note that "blanks" are significant characters in character fields. By using the %trim() builtin, you can get the number of non-blank characters.

Variable-length character fields can show differences between %len() and %size() values -- the %len() varies with the value that is set while the %size() remains unchanged. Packed, integer and binary fields can also show differences. If you take the %size() of a packed variable, it'll usually be a bit more than half of the %len() because the digits are 'packed' into memory.

Tom