What is an Infinite Loop?
An infinite loop error occurs when an earlier script step is listed as the next step of a step that occurs later in the script. In this tutorial you will learn:
- How an infinite loop is created: We'll move a script step up which will create an infinite loop.
- How to fix the scripting error: We'll tell you how to fix the problem.
How an Infinite Loop is Created
You'll most likely get the error when you try to move a script step up to a prior position. For our example below, we've created a script path where the BestTime question is being asked before the Regarding question. However, let’s say that you want to ask the caller the BestTime question after the Regarding question.
1. First, you'll want to click on the step prior to the one you are skipping. In our example, we want to flip-flop the position of the Regarding and BestTime steps. To do this, click on the Address step, since we want Regarding to come immediately after it. Once Address3 is clicked, select your Next Step from the drop down menu on the right. In our case, the next step we want is Regarding3.
2. Click Save. Your path will repopulate on the left, showing Address followed by Regarding, and Closing. This is because Closing originally came after Regarding. But we're not done. We still need to add BestTime after Regarding.
3. To add BestTime after Regarding, click on Regarding, then select BestTime3 from the Next Step drop down menu.
4. Click Save. Your path will repopulate on the left showing the Infinite Loop error. Don't worry. This is happening because before you swapped the paths, BestTime3 was citing Regarding3 as its next step. The problem is that the BestTime step still wants to go to Regarding next, which creates the loop.
How to Fix the Infinite Loop Error
To fix the error, we will simply need to edit the script step before the infinite loop and tell it to go to one of 3 places: a new step, a step that isn't referenced yet in the current path, or a closing step. For our example, we are simply going to close the script.
1. To establish a Closing step and remove the error, click on the step prior to the Infinite Loop symbol, then select Closing3 from the Next Step drop down menu.
2. Click Save. Your path will repopulate on the left showing the steps in your desired order.
Congratulations! You've reorganized your script, you dug yourself out of an infinite loop error, and you successfully closed your script path. Find a coworker and give them a high 5 followed by a fist bump.