Previous Topic: Prevent an Infinite WaitNext Topic: Wait for Specific Data from Application


Prevent an Endless Loop

There are two ways that you can prevent an endless loop:

  1. You can use an accumulator to count the number of times the program executes the loop. Each time the loop is executed, increment the accumulator and compare it to a value (such as 10). Then instruct the program to branch to the end of the program when the accumulator reaches the specified value.
  2. You can place an OPTION statement at the beginning of the program and set the maximum number of instructions that the program can execute. For more details on using the OPTION statement to prevent endless loops, see Prevent Uncontrolled Loops.