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



Hi Brad,

> Assume I have field varField defined as Varying in an RPG
> program.
[SNIP]
> eval varField = '^^^^^^Data^^^^^'
> (Each ^ is a blank)
[SNIP]
> Should varField then equal:
> "^^^^^^Data"

No.  It should equal exactly what you assigned to it.  '^^^^^^Data^^^^^'

> "Data"

No.  It should equal exactly what you assigned to it.  '^^^^^^Data^^^^^'

> If the latter, why?  And how can I get it to equal the
> prior?  My testing shows I am getting the latter (no
> preceeding spaces).

When you assign data to a varying field, it keeps whatever you assigned,
exactly as you assigned it.  Simple, yes?

This is different from a (traditional) fixed-length field.  When you
assign data that's shorter than the field, it will pad that data with
spaces.  Varying does not do the padding.  It takes whatever you've
assigned it, and puts that there, nothing more, nothing less.

Since you've actually included spaces in what you've assigned to it, those
spaces will be there.  No extra spaces beyond what you've assigned to it
will be added, however.

Because RPG programmers have been using fixed-length fields for so long,
they've become accustomed to thinking of the spaces in fields as if they
don't exist -- which causes problems.  So, they compensate for those
problems by trimming the spaces, then adding new spaces back in, etc.
Which creates both ugly code and poor performance.  With varying, they
don't have to do that, just assign the correct spaces in the first place
and you're done.

If you DO have too many spaces in your varying field, you can trim them
with the %TRIMx family of BIFs, just like you could with a fixed-length
field.  The difference is, you can make the change stick so that you don't
have to re-trim it over and over...



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.