ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Debug

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

  • Debug

    Hi,

    When we are debugging some RPGLE program and during this debug we go inside some dow %eof kind of loop
    then on certain record number we want to come out of this loop then how can we come out of this loop and then continue debugging
    after this loop to check other variable values.


    Thanks..

  • #2
    Not sure what you mean
    Do you want to use debug to force the loop to end? Or do you want the program to run until the loop ends and then break for you after the loop?

    Comment


    • John192
      John192 commented
      Editing a comment
      I want forcefully come out of this loop during debug.also for both of these 2 scenarios how can we end the debug randomly? because generally what happens when we debug a program and while debugging once it goes inside loop it becomes difficult to come out of this loop.

  • #3
    If you have code like this:
    Code:
    read rec;
    dow not %eof;
       ...
       read rec;
    enddo;
    Change it to
    Code:
    read rec;
    eof = %eof;
    dow not eof;
       ...
       read rec;
       eof = %eof;
    enddo;
    Then you can change the "eof" variable in the debugger when you want to exit the loop early.

    Comment


    • John192
      John192 commented
      Editing a comment
      it's practically not possible to change the code of multiple programs this way and logical solution i need for this problem to come out of loop while debugging and then proceed to debugging next program statements.

  • #4
    If you can't implement Barbara's suggestion the only way you can do it is to allow the rest of the loop to run. Place a breakpoint on the first statement after the loop and then let the program run. If using RDi rather than using a breakpoint you can use Run to location instead.

    Comment


    • #5
      If the loop is doing a READE or a READPE (i.e. it's reading based on a key value) then you can update the key to a value that will produce EOF.
      If the loop is not doing that then you're out of luck, and your only options are to modify the program, or set a breakpoint after the loop and run to it and wait. There is no feature of IBM i debug that lets you force the return value of the next %eof call.

      Typically running a program in debug is done for fault finding. In which case while it is desirable to debug the exact same program object that has the issue, it's not always essential. So you could create a modified copy of the program with a modified loop (using Barbara's suggestion) that you can end in debug, and then run and debug that copy.

      Comment

      Working...
      X