This article applies to:
Variables in E-Prime are defined and accessible within a scope. That is, variables are temporary and are discarded after the scope (e.g., Procedure) in which they are defined is exited. However, variables declared in the User Script are defined globally. Therefore, their scope spans the entire program.
Global variables can be initialized within the structure of the experiment using an InLine object. Most commonly, the initialization of Global Variables would be in an InLine object at the beginning of the experiment structure. Variables declared globally may be accessed at any point in the structure of the experiment (i.e., their scope includes the entire experiment).
In contrast, a Dim statement within a Procedure, subroutine or function declares variables locally to that Procedure, subroutine, or function. Variables declared within a particular scope are not automatically "seen" outside of that scope. Once that scope is exited, the variable is discarded. For example, a variable declared at the Trial level with the Dim command is discarded after the Trial Procedure is completed.
Global Variables are particularly useful when you wish to keep correct answer totals or block accuracy totals. We recommend using Global Variables when you intend to use the same variable throughout the experiment.
Please sign in to leave a comment.