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



Teri,

No comments on the nested if form?

I'd perform to see that one.  IMHO, it's simpler than having a loop in
there that really isn't needed as it follows the logic of what you are
trying to accomplish.  As an added bonus, it takes less code!

  Check 30
  if not found
    check 10
    if not found
      check 20
      if not found
        set bad
      endif
    endif
  endif

Also, for readability, consider if 10, 20, 30 are magic numbers and
should be replaced by constants:
http://en.wikipedia.org/wiki/Magic_number_(programming)


HTH,


Charles Wilt
--
iSeries Systems Administrator / Developer
Mitsubishi Electric Automotive America
ph: 513-573-4343
fax: 513-398-1121
  

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx 
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of 
THarteau@xxxxxxxxxxxxxxxxxx
Sent: Monday, August 14, 2006 1:43 PM
To: RPG programming on the AS400 / iSeries
Subject: RE: SELECT & WHENEQ Question



Hi,

does order matter?  Yes, we need to check 30 before 10.
give subroutine $100 a decent name! This is the subroutine 
that checks if
a bill of material for the given facility exists. Originally, 
it was one
large(5 printed pages) SR with IF's that started at the 
beginning and ended
at the bottom. Some places had up to 6 ENDIF's, followed by 
an ELSE, then
more ENDIF's.  Everything else has a meaningful name, I just 
missed this
one.

I think I will add the DO and add some comments. Thanks for 
all the help!

<===================================================>

Terri Harteau
Felker Brothers Corporation
****************
"The danger in life is not that we aim too high and miss.
The problem is that we aim too low and hit the mark."  -- Michelangelo
****************






                                                              
             
             "Wilt, Charles"                                  
             
             <CWilt@xxxxxxxxxx                                
             
             om>                                              
          To 
             Sent by:                  "RPG programming on 
the AS400 /     
             rpg400-l-bounces@         iSeries" 
<rpg400-l@xxxxxxxxxxxx>    
             midrange.com                                     
          cc 
                                                              
             
                                                              
     Subject 
             08/14/2006 12:37          RE: SELECT & WHENEQ 
Question        
             PM                                               
             
                                                              
             
                                                              
             
             Please respond to                                
             
              RPG programming                                 
             
              on the AS400 /                                  
             
                  iSeries                                     
             
             <rpg400-l@midrang                                
             
                  e.com>                                      
             
                                                              
             
                                                              
             




I was thinking about that myself.

IMHO, the answer is no.

You could certainly do it, but you'd have to short-circuit 
the for loop
with LEAVE since the for loop really isn't the controlling factor.
Plus you'd have to code to set W@GOOD to 'NO' if you make it 
all the way
through the loop.  The result is ugly, and not clear as to 
why your are
doing what you are doing.

For x = 30 downto 10 by 10;
  K@FAC = %char(x);
  W@GOOD = *BLANKS;
  EXSR $100
  if W@GOOD <> *BLANKS;
    leave;
  endif;
  W@GOOD = 'NO';
Endfor;


Well, I guess that's not as bad as I first envisioned. ;-)  
But it seems
the original code checked '30','10','20'...does order matter?

Still, it seems to me that this is a little clearer as to what you are
doing:

K@FAC = '30';
exsr $100;
if W@GOOD = *BLANKS;
  K@FAC = '10';
  exsr $100;
  if W@GOOD = *BLANKS;
    K@FAC = '20';
    exsr $100;
    if W@GOOD = *BLANKS;
      W@GOOD = 'NO ';
    endif;
  Endif;
Endif;


Oh and Teri, if you're making changes for readability, please, please,
does order matter?!


Charles Wilt
--
iSeries Systems Administrator / Developer
Mitsubishi Electric Automotive America
ph: 513-573-4343
fax: 513-398-1121


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Booth Martin
Sent: Monday, August 14, 2006 1:14 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: SELECT & WHENEQ Question

Rick, would this be a place where using a for/endfor loop would help
clear up future confusion?


rick baird wrote:
Terri,

by removing the DOU, the change in K@FAC isn't re-checked.

put the do back in, and it will return to the top of your
select and recheck.

Rick

On 8/14/06, THarteau@xxxxxxxxxxxxxxxxxx
<THarteau@xxxxxxxxxxxxxxxxxx> wrote:

Hi,
     I am rewriting an old program. It has the following
chunk of code:

C                 MOVE        '30'          K@FAC
C     W@GOOD      DOUNE *BLANK
C                 SELECT
C     K@FAC       WHENEQ      '30'
C                 EXSR        $100
C     W@GOOD      IFEQ        *BLANK
C                 MOVE        '10'          K@FAC
C                 ENDIF
C     K@FAC WHENEQ      '10'
C                 EXSR        $100
C     W@GOOD      IFEQ        *BLANK
C                 MOVE        '20'          K@FAC
C                 ENDIF
C     K@FAC       WHENEQ      '20'
C                 EXSR        $100
C     W@GOOD      IFEQ         *BLANK
C                 MOVE        'NO '         W@GOOD
C                 ENDIF
C                 ENDSL
C                 ENDDO

Basically, it is trying to find the correct bill of
material facility. It
could be in 30, 10 or 20.  I changed it a bit for readability.

C                 MOVE        *BLANK      W@GOOD
C                 MOVE        '30'        K@FAC
C                 SELECT
C*
C     K@FAC       WHENEQ      '30'
C                 EXSR        $100
C                 IF          W@GOOD = *BLANK
C                 MOVE        '10'        K@FAC
C                 ENDIF
C     K@FAC WHENEQ      '10'
C                 EXSR        $100
C                 IF          W@GOOD = *BLANK
C                 MOVE        '20'        K@FAC
C                 ENDIF
C     K@FAC WHENEQ      '20'
C                 EXSR        $100
C                 IF          W@GOOD = *BLANK
C                 MOVE        'NO '       W@GOOD
C                 ENDIF
C*
C                 ENDSL
C*

When I put it in debug, it does the first WHEN, changes
K@FAC to '10', goes
to the next WHENEQ, then goes to the ENDSL.  Can anyone
tell me why it no
longer works?

<===================================================>

Terri Harteau
Programmer/Analyst
Felker Brothers Corporation
****************
"The danger in life is not that we aim too high and miss.
The problem is that we aim too low and hit the mark."  --
Michelangelo
****************




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



--
-----------------------------
Booth Martin
www.martinvt.com
-----------------------------
--
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 ...


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.