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



David

Look at Charles' examples and his more recent post - if you have a 200-character varying field with allocate 0, then there will be only overhead bytes in the primary PF space. I forget how much that is. The actual value contained in the field will be in the auxiliary space, and only so much as the "length" bytes tell it to - the first 2 bytes are an unsigned integer that is the length.

Compare to RPGLE - %size() gives you the declared size of a variable - full length for a varying-length field. %len() gives you the value stored in the first 2 bytes of a varying-length field - typically this is not to include trailing blanks. It's like the result of using %len(%trimr(fixed-length-field)).

In the example I give, of a 200-character varying field, value of 'ABC' will have length of 3 and only 3 bytes are stored in the auxiliary space. '1234567890' will have length of 10 and only 10 bytes are used to store it. That is far from 200. A total of 13 for the 2 records. With fixed-length, it'd be a total of 400 for the 2 records.

Is the mud getting clearer?

Vern

David FOXWELL wrote:
Guys, your explications are perfectly clear and I thank you for them.

However what I was getting at was if I have ALLOCATE(0) for maximum space saving, how do I save space? Is not the data in the overflow plus that of the file not equal to or more than the disk space used without VARLEN? The overflow space must occupy something, somewhere. Or is it just some kind of black hole?


-----Message d'origine-----
De : rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Charles Wilt
Envoyé : mercredi 16 septembre 2009 15:19
À : RPG programming on the IBM i / System i
Objet : Re: Use of VARYING fields

On Wed, Sep 16, 2009 at 8:18 AM, Simon Coulter
<shc@xxxxxxxxxxxxxxxxx> wrote:
On 16/09/2009, at 7:13 PM, David FOXWELL wrote:

After having read up, I have a couple of questions. If you
don't care
about space saving, can't you just code the maximum and allocated
length as the same?
Yes, but what would be the point? That would effectively be
a fixed-
length field with an additional 2-byte length prefix. Might make it
easier to determine actual length of the content but that's all.
Simon,

The point would be, you'd benefit from not having to %trimr()
the fields yet don't pay a i/o hit when accessing any records.

I'd consider such a field as an alternative to a small (say
<50) fixed length field. Particularly in a table access by
native RPG op-codes.
Otherwise you're taking a dual i/O hit for some records even
if you don't need the variable length field. Of course, an
alternative would be to have a logical that didn't include
the varying field(s).

Charles Wilt
--
This is the RPG programming on the IBM i / System i
(RPG400-L) mailing list To post a message email:
RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change
list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.