On 2013/2/25 1:59 PM, CRPence wrote:
Odd that the RPG does not simply return the empty string for the result
of the %subst opcode in that example, and therefore evaluate to false
for the comparison.


I don't necessarily disagree that the behaviour you describe might have been better in the first place, but I'm wondering about other changes that would logically follow from such a change.

Consider this example:
varfld = 'abcde';
n = 4;
m = 5;

%subst(varfld : n : m)

Current rules say that 2 is the maximum value for m in this case. Should the "length" parameter actually just be interpreted as the "maximum length", and a value of 'de' be returned?

We did change the behaviour, without a syntax change, regarding the length parameter of %SUBST being zero. It used to be an error to have a length of zero, but we changed it to just return a zero-length subfield.

But returning a zero-length subfield when a 1-length subfield was specifically requested doesn't seem to me like something that can just be changed without some new syntax requesting that behaviour.

Joep's specific case could be solved by adding an extra check to the if:

if %len(path) > 0 and %subst(path :1 :1) = '/';
// absolute path
else;
// relative path
endif;


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