Database Reference
In-Depth Information
Set Variable [$$chartData ; Value: $chartData & "¶" & Product::Sales]
Set Variable [$$chartLabel ; Value: $chartLabel & "¶" & Product::Name]
Go to Record/Request/Page [Next]
End Loop
The first step inside this loop is a test to see if the looping steps should run. The first time
through the loop, the counter hasn't been set yet, so the test will be false and the loop steps
run. The counter increments 11 times before the Exit Loop If test evaluates as true and the
loop ends. Take care to write a test that exits when you need it to. For example, if the test
were written as $counter = 10 , then the 10th record's data wouldn't be included. You don't
have to put the test at the start of your loop, but if you do, make sure you test the script thor-
oughly before you release it into the wild.
Understanding Types of Loops
A loop that works on a found set of records is called a record loop . A field loop works
through fields within a single record. You can nest one loop inside another, as when you need
to work on a set of parent records and then on each parent's child records. A nested loop's
structure looks like this:
Loop
# Work on the first parent record here
Go to Related Record [From table: ChildTable; Using Layout: ChildLayout ; New
Window]
Loop
# Work on one set of child records here
Go to Record/Request/Page [Next; Exit after last]
End Loop
Close Window [Name: "Child Record Window" ; Current File]
# Go to the next parent record and then start the process over
Go to Record/Request/Page [Next; Exit after last]
End Loop
In this nested loop, the first loop works on a parent record and is called the outer loop . It runs
once for each parent record. The one that works on the child records is called an inner loop
and it runs once for each child record that's related to the currently active parent record. Nes-
ted loops work on many different found sets of records, so it's often easier to set them up and
troubleshoot them by using Go to Related Record steps that open new windows for the
child records and then close the child record window after each loop.
NOTE
You'll get to write a basic looping script on Finishing the Process Timeslips Subscript .
Search WWH ::




Custom Search