Database Reference
In-Depth Information
Using Go to Record/Request/Page to Exit a Loop
The most common, and certainly the simplest, use for a loop is to repeat a process on a found
set of records. Your script will need the steps that find the proper records and any preparatory
work that needs to be done. Use the Go to Record/Request/Page step, and turn on the
“Exit after last” checkbox ( Figure 11-19 ) . When turned on, “Exit after last” exits the found
set (and stops the loop) after the loop's steps have run on the last record in the found set. This
script starts its work on the first record in the found set and repeats the actions represented by
the “#Your script's work goes here” comment once for each record. You can work through a
found set backward by choosing Previous in the Specify pop-up menu and then selecting
“Exit after last.” This makes sense if you want to leave the user on the first record in a found
set at the end of a loop.
Figure 11-19. When Next is selected in the Specify pop-up menu, the Go to Record/Request/
Page script step has an “Exit after last” option.
Using Exit Loop If to Exit a Loop
There are times when an If test is a better way to exit a loop, as when you need to deal with
the first few records in a found set. For instance, you might want to chart the data from your
top ten best selling products. You'd find all your products, sort them by sales volume and
then loop through them, setting the data the chart needs into a global variable. The looping
part of that script might look like this:
Loop
Exit Loop If [ $counter > 10 ]
Set Variable [$counter ; $counter + 1]
Search WWH ::




Custom Search