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



Huh?? How does this help?

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx

-----rpg400-l-bounces@xxxxxxxxxxxx wrote: -----
To: "RPG programming on the IBM i / System i" <rpg400-l@xxxxxxxxxxxx>
From: Dave
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
Date: 07/01/2011 03:54PM
Subject: Re: RPG Free Lesson

Also, how can you just code %error when you don't seem to know what it is for?

2011/7/1 Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>:

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!!

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