× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Instead of %prefixsize, why not a %varysize bif that gave you the "usable" length of the field.

I agree... but we also need the address of the data, not just the length, but I agree with the sentiment. I'd rather omit the math entirely and have RPG tell me where the address of the data is, and what the max length of the data is.

Remember that VARYING also applies to UCS2 and Graphic fields in addition to alpha fields. So %size(MyVary) - %prefixSize(MyVary) isn't always enough. You'd also need %size(MyVary) / %size(OneChar) - %prefixSize(MyVary) and it just gets uglier and uglier.

Whereas, something like %len(MyVary: *max) (or your suggestion of %varysize() which does the same thing) that would give the maximum amount of CHARACTERS (not bytes) in one fell swoop would be much less ugly.

I'm not quite sure I really understand why the index was ever exposed to RPG, and to me %size should have given MaxDataLen from the get go, but I digress...

When IBM created the %size() BIF they really didn't do it for the purpose of maximum length of the string... It just works out that way with the alpha data type because there's one character per byte.

%size() is supposed to report the number of bytes of actual storage. For example, if you use a BASED field and use dynamic memory allocation, %size() should report the number of bytes you need to allocate, and the number of bytes you need to offset the pointer to skip past the field, etc.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.