Commands
ForEach [# of loops]
ForEach [filespec, i. e. ”C:\data\DR*.txt”]
ForEachSheet
Next
Regenerate
Explanation
The heart of many scripts is a loop. You can loop a certain number of times (for simulations), over all matching files (repeated importing), or over all sheets in a section (to print or export…). End the loop with a Next statement. You cannot nest loops.
Starting and ending the loop
There are three ways to start a loop:
•Loop a specified number of times (example): ForEach 100.
•Loop over a set of files (example): ForEach *.CSV
•Loop over all sheets in the current section: ForEachSheet
For all three kinds of loops, the Next statement ends the loop.
Regenerate random numbers
One common use of a Prism script is to do Monte Carlo analyses. First create a Prism file that uses the analysis ‘Simulate data with random scatter” to generate data, and links those simulated data to another analysis (say a nonlinear regression). Inside each loop, use the GoTo command to go to the analysis page that generates the data, and use the Regenerate command to create new ‘data’ (with different random scatter). Then go to the results, write out selected results, and use the Next command to loop again. See script example 2 at the beginning of this chapter.