Learn how to a build a cloud-first strategyRegister Now


Difference between %len and %size

Posted on 2005-05-15
Medium Priority
Last Modified: 2008-02-26
what is the difference between %len and %size built in function with an example?
Question by:mayankgangrade
LVL 14

Accepted Solution

daveslater earned 200 total points
ID: 14006292
%LEN = The length of the contents of a field - if the field is varying length then this coould be less than the size
%size = The size and is fixed.


Str = stringf fld 30 bytes and Holds 'Hi Dave'

%size = 30
%trim(%len)) = 7

if it was defined as varying then
%size = 30

LVL 27

Expert Comment

ID: 14030524

%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.


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

LinkedIn blogging is great for networking, building up an audience, and expanding your influence as well. However, if you want to achieve these results, you need to work really hard to make your post worth liking and sharing. Here are 4 tips that ca…
Exchange administrators are always vigilant about Exchange crashes and disasters that are possible any time. It is quite essential to identify the symptoms of a possible Exchange issue and be prepared with a proper recovery plan. There are multiple…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month21 days, 4 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question