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



If you always want this data to be first,

XCVAR1 = 'false' + XCVAR1;

ought to work as it's defined as varying.

Otherwise, as John and others pointed out, you need to be sure to tell RPG
that you do have enough room for the data -- via the length. Yes, there's
always enough room allocated, but RPG won't use more than %len() characters
of it.

There is good info in the RPGLE reference about when the length is set, how
it is set, and what heppens to the data when the length is set.

Stu



On Mon, Feb 27, 2012 at 13:46, Loek Maartens <l.maartens@xxxxxxxxx> wrote:

Hello group,

I have a field named XCVAR1 in a database file with a size of 150 bytes
defined with the DDS keyword VARLEN (no size specified).

I understand that this field initially has a length of zero.

Just setting the field XCVAR1 works;

XCVAR1 = 'false' ;

but there might be other values in this VARLEN defined field that I should
leave intact (and at the same offset) when they were set by other programs.

When trying to set the field to a value like:

%subst(XCVAR1:1:5) = 'false';

the programs throws an error complaining about invalid field size.

If I first set the XCVAR1 field size like;

if %len(XCVAR1) < 5;
%len(XCVAR1) = 5;
endif;

all is well.

Should the compiler not just set the length of XCVAR1 to 5 when I assign
the
value 'false' if the XCVAR1 length is less then the value I want to set
using the %subst function or can someone explain why not?


Kind regards,

Loek Maartens.


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

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.