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



Working as designed I'd say....

Think of it as the same error you'd get if the field was defined as
char(10) and you tried to %subst(XCVAR1:15:5)....

I think the code you posted is a good solution...

Charles

On Mon, Feb 27, 2012 at 2:46 PM, 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 ...

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.