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



I don't know why this statement fails on V4. My best guess is that the V4 level compilers incorrectly assume that the intermediate result is an unsigned number. It's true that the output of the %scan() BIF is an unsigned number, but when you subtract 1 from it, the intermediate result SHOULD be a signed number (and it is in V5). I can only guess that this is a bug in the older compilers that IBM fixed before V5R1 was released.

An easy workaround is to make the code look like this:

c eval pos = %scan('?': path)
c eval pos = pos - 1

That should achieve the exact same results, but since the subtraction is on a separate statement, the compiler should make a different decision about the intermediate result.


James Lampert wrote:
Given that "path" is 32767A, and VARYING, and that POS is either 10I or 29P 0, why would

eval pos = %scan('?': path) - 1

give an MCH1201 error when executed?

Compiler is V4R2; OS is V4R4. Also fails under V4R5. Also fails if "path" is 255A VARYING.



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.