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




Very peculiar way of writing code.

You want to report the same error to the user when a record isn't found that you report when a record is locked, or an index is damaged?

Your subject says "RPG Free Lesson", yet this doesn't seem to have anything to do with free format RPG. Compare the following fixed-format code:

C MYKEY KLIST
C KFLD DORDN
C MYKEY CHAIN(e) IPE500CH
C If %found
C HCPO dsply
c Else
c eval MSGID = 'MOP0005'
c eval LINE = '8'
c exsr SendMsg
C ENDIF

Sure, the fixed format code is harder to read (because it lacks indentation), but otherwise, it's identical and would behave exactly the same. So what does %FOUND and %ERROR have to do with whether you're using free format or fixed format?

Personally, if I wasn't planning to treat errors differently from missing records, I'd omit the (E) extender.

CHAIN (DORDN) IPE500CH;
If %found;
dsply HCPO;
Else;
MSGID = 'MOP0005';
LINE = '8';
Exsr SendMsg;
ENDIF;

This will send you a halt if an actual error (as opposed to "record not found", which isn't an error according to RPG) occurs.



On 7/1/2011 9:21 AM, Billy Waters wrote:
CHAIN(e) (DORDN) IPE500CH;
If %found;
dsply HCPO;
Else;
MSGID = 'MOP0005';
LINE = '8';
Exsr SendMsg;
ENDIF;

returns the expected results. Thanks!!


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.