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



Your error had nothing to do with it being a packed number (that would be a compiler error if a packed number was not allowed) but rather the fact that the parameter wasn't an integer. You may have known that the value always contained whole numbers, but the compiler can't make that assumption. Since you can't take a substring that starts in the middle of a character, you can't have decimal places in the start position.

You can prove this to yourself by forcing the calculation to be an integer e.g. somevar = %SUBST(somevar: 5: %Int(parm_length - 4));

On Sep 7, 2019, at 12:28 AM, Javier Sánchez <javiersanchezbarquero@xxxxxxxxx> wrote:

Today I was compiling a program in which a wanted to assign a substring
some value from a starting point, and this was a variable of type
PACKED(15:5) which in time I defined like that because it comes from the
command line. I had a compiler error claiming that the type of parameter 3
was in fact an expression like:
somevar = %SUBST(somevar: 5: parm_length - 4);

where parm_length comes as a parameter from the command line as a
PACKED(15:5). This was the cause of the error. I decided to declare
another INT(10) variable to which I assigned the value of parm_length minus
4 and replaced it in parameter 3 of the %SUBST. And it compiled. I didn't
have the time to investigate that but I could solve the inconvenience.

I would imagine that maybe something like that could be bothering you as
your variable for the starting point is exactly a PACKED(5) one. Maybe
PACKED variables are not welcome in %SUBST now.

It's only an opinion that would probably have more comments by the way.

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

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com


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.