Phases

A phase is simply a part of the overall experiment.  Phases play a key role in Experimentor (as they typically do in scientific research too).  

Phases are typically defined inside a Trial, but they can be defined directly within the codes as well (as the following examples demonstrate).

It is possible to “goto” a phase, and to “run” a phase (and there is a subtle difference).  

Goto phase

When you “goto” another phase the program does not come back.  For example, the following codes:

define phase ParentPhase

       print(“Inside Parent – start”)

       goto phase ChildPhase

       print(“Inside Parent – end”)

end phase


define phase ChildPhase

       print(“Inside Child”)

end phase


run phase ParentPhase


print out:

Inside Parent – start
Inside Child

and then the codes end.  “Inside A – end” is never printed, and in fact that  print statement is unreachable.  Specifically, ParentPhase stops running, and all the variables defined within the ParentPhase are cleaned up (and cease to exist).  Then the ChildPhase is run, and it can do whatever it wants.

Run phase

When you “run” a phase the program runs that phase and then returns to where the run call is and continues running the code.  For example, the following codes:

define phase ParentPhase

       print(“Inside Parent – start”)

       run phase ChildPhase

       print(“Inside Parent – end”)

end phase


define phase ChildPhase

       print(“Inside Child”)

end phase


run phase ParentPhase


prints out:

Inside Parent – start
Inside Child
Inside Parent – end

and then the codes end.  That is, when the ParentPhase “runs” the child phase, the child phase runs, and when it is done it returns to the parent phase and continues executing.  In this way, “run” is a little bit like a function call in other languages.  However, when invoked with “run”, the ChildPhase actually has access to all the variables in the ParentPhase, because it runs within the parent phase’s variable scope.  This simplifies the calling semantics significantly (because there are no pass-by-value or pass-by-reference concerns – there is no “pass-by” anything because phases don’t have arguments).