Repeating Experiments using Autoscripts

Repeating Experiments using Autoscripts

NOTE: With the advent of the Sequence Wizard, creating auto scripts is unnecessary. We include the discussion pages concerning auto scripts for the sake of completeness, and instead, recommend you use the Sequence Wizard for automated experiments.

To repeat one experiment a certain number of times, copy one call to LaunchWait() as many times as you need. Although this technique works for small numbers of experiments, a better solution for large numbers of experiments is to create a loop to repeat that experiment.

A sample master script was created to repeat one experiment multiple times. Find it in the file REPEAT1.EXP.

include “explain.exp”

include “Auto Utilities.exp”

 

function Main()

if (WakeUp(“15:30:00”,NIL) eq FALSE) ; NIL implies Today.

return

BaseName = “rpdata”

i = 1

Cycles = 5

while (i le Cycles)

FileName = Sprint(BaseName,i,”.dta”)

if (Delay(10) eq FALSE)

return

if (LaunchWait(“Auto Polarization Resistance.exp”,”auto.set”,”Rp Setup”,FileName,1,NIL)

& eq FALSE)

return

i = i + 1

Notify(“All Experiments Done”)

Dawdle()

You can modify REPEAT1.EXP. Use File > Open to edit it, but remember to save your changes under a new script name using the File > Save As command.

REPEAT1.EXP creates the output filenames automatically by combining a base filename with a loop number and a .dta file extension. In this case the master script is running a polarization resistance experiment five times with the base filename of rpdata, so the output files are named RPDATA1.DTA through RPDATA5.DTA. To change the output filenames, edit the line where the script sets BaseName to rpdata. Change the number of times the experiment runs by changing the value of Cycles.

Because the base filename is combined with a cycle number to generate the output filename, be careful that the base filename plus the total number of cycles is less than 256 characters.

The call to Delay() controls how much time passes between the end of one experiment and the start of the next, while LaunchWait() controls the actual start time of the experiment. Edit these lines to fill in your own preferences for the time delay and the actual experiment run. The only precaution here is to avoid accidentally replacing the FileName parameter in the call to LaunchWait(). The other parameters are used the same way as in RUN MANY.EXP.

From a beginner’s standpoint, this script is more complicated than RUN MANY.EXP but it does illustrate some of the flexibility that the Explain™ scripting language offers. For example if you want to run three different experiments followed by ten repetitions of one experiment, followed by two different experiments and then another loop, you could easily create a new master script by copying portions of RUN MANY.EXP and REPEAT1.EXP as needed to set up your particular experiment sequence. You can also do anything in a master script that you can do in a regular script, such as opening a file, writing notes, etc.