× 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 Nice.  I'll have to keep that in mind for next time.

Ron Power
Programmer
Information Services
City Of St. John's, NL
P.O. Box 908
St. John's, NL
A1C 5M2
Tel: 709-576-8132
Email: rpower@xxxxxxxxxx
Website: http://www.stjohns.ca/
___________________________________________________________________________
Success is going from failure to failure without a loss of enthusiasm. - 
Sir Winston Churchill




"Joe Lee" <LeeJD@xxxxxx> 
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
31/01/2005 02:20 PM
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>


To
<rpg400-l@xxxxxxxxxxxx>
cc

Subject
Re: Suggested technique






How about using a select statement.
      * Stay in loop until Cmd 1 is pressed
     c                   dow       not(*in01)
     c                   eval      action    = *blanks
     c                   eval      category  = *blanks
     c                   eval      descriptn = *blanks
     c                   exfmt     cbrdescdt
     c                   movea     '0000000'     *in(30)
     c                   select
      *
      * F5 will print report
     c                   when    *in05     = *on
     c                   eval      *in50     = *on
     c                   exsr      print
      *
      * Just a little error check to help keep ya in line.
     c                   when    action    = *blanks
     c                   eval      *in31     = *on
      *
      * Add a record to the file
     c                   when     action    = 'A'
     c     category      chain     crltycdr
     c                   if        not %found(crltycd)
     c                   exsr      error_check
     c                   if        NOT (*in32 = *on   or
     c                             *in33 = *on)
     c                   eval      crlcat    = category
     c                   eval      crldesc   = descriptn
     c                   write     crltycdr
     c                   endif
     c                   else
     c                   eval      *in30     = *on
     c                   endif
      *
     c                   when      action    = 'C'
     c     category      chain     crltycdr
     c                   if        %found(crltycd)
     c                   eval      *in35     = *on
     c                   exsr      get_record
     c                   exsr      error_check
     c                   if        NOT (*in32 = *on   or
     c                             *in33 = *on)
     c                   eval      crlcat    = category
     c                   eval      crldesc   = descriptn
     c                   update    crltycdr
     c                   endif
     c                   else
     c                   eval      *in34     = *on
     c                   endif
      *
     c                   When      action    = 'D'
     c     category      chain     crltycdr
     c                   if        %found(crltycd)
     c                   movea     '11'          *in(35)
     c                   exsr      get_record
     c                   exfmt     cbrwindow
     c                   if        *in12     = *Off
     c                   delete    crltycdr
     c                   endif
     c                   else
     c                   eval      *in34     = *on
     c                   endif
     c                   endsl
     c                   enddo
     c                   eval      *inlr     = *on 

That should be functionally equivalent, doesn't need any iters, and is
several lines shorter.

Joe Lee


>>> RPower@xxxxxxxxxx 01/31/2005 09:15:42 >>>
What's wrong with the Iter and Leave op codes?  I've used them a lot in

the past, and will probably continue to do so in the future.  I don't
like 
the GOTO's and CAB's, but the LEAVE and ITER just make sense. 
Especially 
in screen processing.  The following code is a looping screen.  The
ITER 
code helps when doing validation, and the LEAVE is a simple way to get

out.  How could you code this without using them?  BTW, this isn't my 
code, but I was looking real quick to find an example lol.

      * Stay in loop until Cmd 1 is pressed
     c                   dow       not(*in01)
     c                   eval      action    = *blanks
     c                   eval      category  = *blanks
     c                   eval      descriptn = *blanks
     c                   exfmt     cbrdescdt
     c                   movea     '0000000'     *in(30)
      *
      * F5 will print report
     c                   if        *in05     = *on
     c                   eval      *in50     = *on
     c                   exsr      print
     c                   iter
     c                   endif
      *
      * Just a little error check to help keep ya in line.
     c                   if        action    = *blanks
     c                   eval      *in31     = *on
     c                   iter
     c                   endif
      *
      * Add a record to the file
     c                   if        action    = 'A'
     c     category      chain     crltycdr
     c                   if        not %found(crltycd)
     c                   exsr      error_check
     c                   if        *in32 = *on   or
     c                             *in33 = *on
     c                   iter
     c                   endif
     c                   eval      crlcat    = category
     c                   eval      crldesc   = descriptn
     c                   write     crltycdr
     c                   else
     c                   eval      *in30     = *on
     c                   iter
     c                   endif
     c                   endif
      *
     c                   if        action    = 'C'
     c     category      chain     crltycdr
     c                   if        %found(crltycd)
     c                   eval      *in35     = *on
     c                   exsr      get_record
     c                   exsr      error_check
     c                   if        *in32 = *on   or
     c                             *in33 = *on
     c                   iter
     c                   endif
     c                   eval      crlcat    = category
     c                   eval      crldesc   = descriptn
     c                   update    crltycdr
     c                   else
     c                   eval      *in34     = *on
     c                   iter
     c                   endif
     c                   endif
      *
     c                   if        action    = 'D'
     c     category      chain     crltycdr
     c                   if        %found(crltycd)
     c                   movea     '11'          *in(35)
     c                   exsr      get_record
     c                   exfmt     cbrwindow
     c                   if        *in12     = *on
     c                   iter
     c                   endif
     c                   delete    crltycdr
     c                   else
     c                   eval      *in34     = *on
     c                   iter
     c                   endif
     c                   endif
     c                   enddo
     c                   eval      *inlr     = *on 


Ron Power
Programmer
Information Services
City Of St. John's, NL
P.O. Box 908
St. John's, NL
A1C 5M2
Tel: 709-576-8132
Email: rpower@xxxxxxxxxx 
Website: http://www.stjohns.ca/ 
___________________________________________________________________________
Success is going from failure to failure without a loss of enthusiasm.
- 
Sir Winston Churchill




Tony Carolla <carolla@xxxxxxxxx> 
Sent by: rpg400-l-bounces@xxxxxxxxxxxx 
31/01/2005 01:27 PM
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>


To
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
cc

Subject
Re: Suggested technique






Hi Alan.  Thanks again for the tip. 

I always grapple with the idea of not using iter and leave also.  I
don't see how it makes the code clearer to the reader, by eliminating
these ops.  I took your example, and eliminated the iter, as follows:


Dou iSay;
    iSay=*On;
 
    // Find next memo seq# for member
    SetGT(E)  (CI.Family#:CI.Member#) Mmemo_I;
    ReadPE(E) (CI.Family#:CI.Member#) Mmemo_I MI;
 
    If %Found(Mmemo_I);
       MO.Mmseq#=MI.Mmseq#+1;
    Else;
       MO.Mmseq#=1;
    EndIf;

    Monitor;
            Write Mmorec MO;

            On-Error *File;
               iSay=*Off;
    EndMon;
EndDo;

Now this is a very simple loop, and doesn't even transcend a page, but
in general, while perusing the code, you have to look to the beginning
of the loop to determine the condition of the loop.  If using iter,
you also have to peruse to the top of the loop anyways, so what's the
diff?


-- 
"Enter any 11-digit prime number to continue..."
-- 
This is the RPG programming on the AS400 / iSeries (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.


-- 
This is the RPG programming on the AS400 / iSeries (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.

-- 
This is the RPG programming on the AS400 / iSeries (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.