sponsored links

Collapse

Announcement

Collapse
No announcement yet.

Endless loop with no commit

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

  • john.sev99
    commented on 's reply
    Lol, I think I have the same OCD problem, I've never liked infinite loops and code in the same way as you. I also think it's more human readable.

  • Barbara Morris
    replied
    Hi Birgitta, I can't believe I forgot about ON-EXIT. That would work perfectly for this.

    Leave a comment:


  • Rocky
    replied
    Originally posted by Barbara Morris View Post
    In the future, if you have an endless loop with some code you need to run after the loop, use the %SHTDN built-in function within the loop to see if the job is trying to end. If %SHTDN returns true, then exit the loop. (And make sure you end the job *CNTRLD to give it time to do the code after the loop.)

    Code:
    dow 1 = 1;
    ... some code ...
     if %SHTDN();
    leave;
    endif;
    enddo;
    I know I'm weird - but having something exit a loop from within is one of those OCD things that drives me crazy - I tend to treat loops like procedures - one entry point and one exit point....

    Code:
    exitloop = %SHTDN();
    dou exitloop;
    ... some code ...
       exitloop = %SHTDN();
    enddo;
    This allows you to get into debug and set exitloop to '1' manually for debugging purposes. You have 1 entry point - DOU - and one exit - ENDDO

    Leave a comment:


  • B.Hauser
    replied
    Barbara,

    wouldn't ON-EXIT work, too?

    Code:
    Dow 1=1;
      ... whatever you do
    EndDo;
    
    On-Exit;
      Commit;
       ... or whatever you want to do
    Birgitta

    Leave a comment:


  • Barbara Morris
    replied
    In the future, if you have an endless loop with some code you need to run after the loop, use the %SHTDN built-in function within the loop to see if the job is trying to end. If %SHTDN returns true, then exit the loop. (And make sure you end the job *CNTRLD to give it time to do the code after the loop.)

    Code:
    dow 1 = 1;
       ... some code ...
       if %SHTDN();
          leave;
       endif;
    enddo;

    Leave a comment:


  • Trentation
    replied
    Thanks for the replies, I had to end the job and restart. The do while condition was 1=1 and so I couldn't force the change in debug.

    Leave a comment:


  • tomholden
    replied
    put the job in debug & force the condition to exit the loop is the only way i can think of

    Leave a comment:


  • Vectorspace
    replied
    Just to confirm - you want to know if there is a way to manually end an existing running job that has activation group *NEW, so that it will commit all outstanding updates?

    Leave a comment:


  • Trentation
    started a topic Endless loop with no commit

    Endless loop with no commit

    I have created a situation. I have an RPGLE program that is in a endless do-while loop running embedded sql statements to update data. It is done its work, but due to a logic problem it never reaches the exit point of the loop. It's in a *new activation group, and so if I end the job it never commits and I lose all of the work it has done. I would much rather find a way to end the program and commit the changes.

    Any ideas?
Working...
X