ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

COMP opcode with indicators

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • COMP opcode with indicators

    Ok, I'm converting a program flow written in RPG using COMP opcode into RPGIV. Code is below:

    Code:
    	   
               KEY	CHAIN	       FILEA	       	10
    	  *IN10	DOWNE	       '1'
    	  VAR1	COMP	       VAR2		2727
          27VAR3	COMP	        '0'		        27
          27VAR4	COMP        	'D'		2727
         N27KEY       READE	       FILEA		10
         N27	        ENDDO
    The confusing part for me is the lines of code that uses COMPARE. The way I understand is that this is what will happen.

    1) If VAR1 and VAR2 are not equal, *IN27 is *ON.
    2) The second compare of VAR3 will be processed if *IN27 is *ON. If VAR3 is equal to '0', *IN27 = *ON. Otherwise, *IN27 = *OFF.
    3) If *IN27 = *ON, VAR4 is compared to 'D'. If VAR4 = 'D', *IN27 is switched *OFF. Another round of READE is done and VAR4 checking is skipped.

    If my assumptions are correct, I plan to convert the logic into the following:

    Code:
    KEY  CHAIN  FILEA   
    DoW  Not %EoF(FILEA)
    
    If VAR1 <> VAR2
    	If VAR3 = 0 and VAR4 <> 'D'
    		...several more statements
    	EndIf
    EndIf
    KEY  ReadE  FILEA   
    Enddo
    Any feedback is greatly appreciated. Thanks!

  • #2
    Re: COMP opcode with indicators

    Welcome back after such a long time... or have you just been lurking?

    Check out this thread http://www.code400.com/forum/showthread.php?t=6631

    A few of the good folk here have come up with some good solutions (i.e. various ways) to answer exactly the same question.
    Last edited by kitvb1; January 22, 2009, 09:59 AM.
    Regards

    Kit
    http://www.ecofitonline.com
    DeskfIT - ChangefIT - XrefIT
    ___________________________________
    There are only 3 kinds of people -
    Those that can count and those that can't.

    Comment


    • #3
      Re: COMP opcode with indicators

      Hi hockeygrl:

      This is my version:
      Code:
                  
      dow var1<> var2 and var3 = 0 and var4 <> 'D' 
              or not %found(filea);
                   reade key filea;
      enddo;

      This statement from the origional code says if all of the above is false do the read:
      Code:
      [COLOR=blue]N27[/COLOR]KEY       READE           FILEA        10
      Best of Luck
      GLS
      Last edited by GLS400; January 22, 2009, 10:28 AM. Reason: missed the *in10 re-wrote the code
      The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

      Comment


      • #4
        Re: COMP opcode with indicators

        Originally posted by GLS400 View Post
        Hi hockeygrl:

        This is my version:
        Code:
                    
        dow var1<> var2 and var3 = 0 and var4 <> 'D' 
                or not %found(filea);
                     reade key filea;
        enddo;
        I think your or not %found( filea ) should be and %found( filea )

        as in:


        dow %found( filea ) and var1 <> var2 and var3 = 0
        and var4 <> 'D' ;

        As a matter of standard, I put the file condition in my expression first. Also, I would convert to the setll and reade instead of the chain since we are performing another reade in the loop, but this is also just a matter of preferance.

        Code:
        setll ( key ) filea;
        reade ( key ) filea;
        
        dow %found( filea ) and var1 <> var2 and var3 = 0 
                            and var4 <> 'D' ;
          //  do stuff
        
            reade key filea;
        enddo;
        Last edited by MichaelCatalani; January 22, 2009, 11:48 AM.
        Michael Catalani
        IS Director, eCommerce & Web Development
        Acceptance Insurance Corporation
        www.AcceptanceInsurance.com
        www.ProvatoSys.com

        Comment


        • #5
          Re: COMP opcode with indicators

          I think your or not %found( filea ) should be and %found( filea )
          Well you know mike there's a word for that.......

          OOPS

          Good catch
          GLS
          The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

          Comment


          • #6
            Re: COMP opcode with indicators

            Originally posted by kitvb1 View Post
            Welcome back after such a long time... or have you just been lurking?
            Haha! I haven't been able to check out any AS400 forums really for a long time because of work. Besides, most technical issues in RPGILE, I am able to either just review the ibm manual or ask my colleagues about it. However, old-style RPG such as conversion of COMP opcode is a different matter. Just got more confused reading the manuals.

            Thanks for the link btw. It most certainly helped since my problem really is if my understanding of the COMP codes were correct.

            I'll take into account all the suggestions with the way FILEA is read. Thanks you guys!

            Thank God I still remember my login information even if it's been years!

            Comment

            Working...
            X