In Chapter 5, "Creating Data Reports," we showed you how to constrain or extend existing found sets. This capability is also available in any script that uses the Perform Find step. Using the basic script that we created earlier in this chapter, we can use Perform Find to constrain or expand a found set that you've previously used in the database.
1 .Choose Scripts > ScriptMaker (Control+Shift+S/Command+Shift+S).
2 .Double-click the Print Report script you created in "Creating a Basic Script" earlier in this chapter.
3 .When the Edit Script dialog box appears, click the Perform Find step in the script-assembly list on the right.
4 .
In the Script Step Options section, check the "Specify find requests" box (Figure 7.35).
5 .When the Specify Find Requests dialog box appears, select a previous Find Request from the list, or click New to create a new request.
In our script, we select a recent request for sales above $1000 (Figure 7.36).
6 .
Click Edit. When the Edit Find Request dialog box appears, highlight the current Find Request.
7 .With the Find Request highlighted, select from the "Find records when:" scrolling list the field you'd like to use to extend or constrain the found set (Figure 7.37).
In our example, we select the State record to constrain our set to sales above $1000 in one state.
8 .Type the additional criteria in the Criteria box on the right, then click Add (Figure 7.38).
9 .Click OK (Figure 7.39). Click OK three more times to finish.
When you run the script, it will only find the records from the selected state that are contained in the existing found set.
You can select multiple noncontiguous steps in a script by using the Control/Command key instead of Shift.
Copying multiple steps in a script and editing them makes it easy to combine script steps, but it also can make for scripts that are long and hard to read. Your scripts will be cleaner and more professional if you replace duplicated steps with one sub-script that you call when needed. Your master script for printing reports will then be shorter and much easier to understand. Remember that the scripts must run in the right order, with sort commands coming after find steps.