ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to mimic DOU iter op code in a DOW?

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

  • How to mimic DOU iter op code in a DOW?

    Hello,

    Im a user of the DOU loop, but Im being forced to do the DOW now ...

    I used the "ITER" in the DOU to bypass the rest of a DOU loop and go back to reading a new record. But that doesnt work in a DOW, it goes into a loop.

    How can I mimic the DOU behavior in a DOW without using the GOTO op.

    Thank You

  • #2
    Re: How to mimic DOU iter op code in a DOW?

    Why would you be forced to use DOW? Just curious, as the answer to that may control the answers we could offer up.
    Michael Catalani
    IS Director, eCommerce & Web Development
    Acceptance Insurance Corporation
    www.AcceptanceInsurance.com
    www.ProvatoSys.com

    Comment


    • #3
      Re: How to mimic DOU iter op code in a DOW?

      New Standards.

      Not to start a thread or something, but I believe that DOW doesnt lend itself to a structured approach.

      Using goto's is not the approach I would choose to use. That's all Im goign to comment about this.

      Comment


      • #4
        Re: How to mimic DOU iter op code in a DOW?

        Not sure I'm understanding exactly, but do you mean something like this?
        Code:
        DoW not %eof(MYFILE);
          Read MYFILE;
          If not %eof(MYFILE);
            [Do some stuff]
          EndIf;
        EndDo;
        Anyway, odd that programming standards would exclude usage of DoU... avoiding GOTO I can understand, but DoU...?
        Last edited by Viking; August 19, 2013, 09:22 AM.

        Comment


        • #5
          Re: How to mimic DOU iter op code in a DOW?

          DOW and DOU do almost exactly the same thing, and work almost exactly the same way. There's only the slight difference that DOW tests it's condition at the top of the loop, and DOU tests it's condition at the bottom of the loop. Otherwise, they are identical.

          ITER works exactly the same in both. So does LEAVE.

          Neither is more structured than the other, neither should be preferred over the other for a "standard".

          Use the right tool for the specific task you are coding at the moment.

          Comment


          • #6
            Re: How to mimic DOU iter op code in a DOW?

            Originally posted by davisty View Post
            New Standards.

            Not to start a thread or something, but I believe that DOW doesnt lend itself to a structured approach.

            Using goto's is not the approach I would choose to use. That's all Im goign to comment about this.
            No problem about commenting. I figured it was some sort of company standard. The reason I asked though is because I have seen shops have a standard against using the iter op-code as well. (In fact, I have not seen a standard against the use of dou, but have against iter.)

            The key to not getting into a loop, as some have already shown, is to ensure the read operation in your loop is above your iter statement. Iter will jump to the enddo statement, so if your read is after your iter, the read statement will not get performed on an iter and you will enter into an endless loop.
            Michael Catalani
            IS Director, eCommerce & Web Development
            Acceptance Insurance Corporation
            www.AcceptanceInsurance.com
            www.ProvatoSys.com

            Comment


            • #7
              Re: How to mimic DOU iter op code in a DOW?

              [QUOTE=MichaelCatalani;72355] I figured it was some sort of company standard. The reason I asked though is because I have seen shops have a standard against using the iter op-code as well. (In fact, I have not seen a standard against the use of dou, but have against iter.)
              QUOTE]

              I was guessing the same. We have a standard here which requires that you avoid ITER and LEAVE statements as they are considered one step removed from the evil GOTO.
              You don't stop playing games because you get old, You get old because you stop playing games!

              Comment

              Working...
              X