Progress
Programming
Handbook
Infinite Loop Protection
If a statement within a block forces an undo and retry of the block, an infinite loop is possible. That is, it is possible that whatever caused the block to be undone and retried the first time (whether it is a condition such as ERROR or an explicit UNDO statement), may recur during the retry. If Progress detects that such an infinite loop would occur, then it does not retry the block. Instead it performs the NEXT iteration of a FOR EACH block or iterating DO block; it performs a LEAVE on a REPEAT block, procedure block, trigger block, or non-iterating DO block.
Progress detects that an infinite loop would occur if the following conditions are true:
If the block contains statements that block for input, then Progress assumes the user can prevent an infinite loop by supplying different input. If the block contains a reference to the RETRY function then Progress assumes that you have done your own programming to avoid infinite loops.
For example, the following code specifies that the DO block should be retried if the FIND statement produces an error. However, this would lead to an infinite loop (with i always equal to 1) if the specified record does not exist:
If you run this procedure, Progress performs a NEXT rather than a RETRY when an error occurs. Therefore, you see the displayed value of i iterate from 1 to 10. After the tenth error, the procedure ends. Thus, the infinite loop is avoided.
In the following example, the RETRY function is referenced before the statement that causes the error. Therefore, Progress does not detect that an infinite loop occurs on retry:
If you run this code, Progress enters an infinite loop in which i is always 1. Because the RETRY function is referenced before the error, Progress assumes that you are handling the infinite loop problem. You can fix this by changing the ON ERROR phrase to perform a NEXT or LEAVE rather than a RETRY. Alternately, you can perform some processing when RETRY is true that changes the value of i.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |