• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8. Working with Conditional Scri... > Using Counters to Control Loops

Using Counters to Control Loops

Just as the If step is made more flexible and dynamic by the addition of Else, so is looping improved by the Exit Loop If step. If you don't want a loop to continue through every record in your database (and lots of times you really don't!), Exit Loop If provides a way to target your loop to a specific number or group of records.

There are many ways to define your exit point, but one of the most elegant methods is with a counter. Counters do precisely that: You can set them to start at zero, or any other number you need. When it comes to loops, counters are particularly useful in keeping track of how many times a loop has run, allowing you to stop it after as few or as many iterations as you need. For example, in this script we use a counter with the Exit Loop If to print only ten invoices at a time.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint