User`s guide

E-Prime User’s Guide
Chapter 4: Using E-Basic
Page 133
4.3.3.1 Commands
Commands are used to instruct the program to perform an operation. For example, the Run
command is used to launch the object named "Stimulus" within the experiment script.
Stimulus.Run
Commands may or may not take parameters. A listing of all commands associated with particular
objects is available in the E-Basic Online Help.
4.3.3.2 Functions
Like commands, functions are used to instruct the program to perform an operation. In contrast
to commands, however, functions are used to perform an operation that returns a value.
Functions may also be used within a script statement. For example, a function could be written to
calculate the mean value for a set of values. Once defined as a function, a single line of script
would be necessary to run the function to calculate a mean.
4.3.4 Variable Declaration and Initialization
4.3.4.1 Declaring Variables
Variables are distinguished from attributes in that they are not specifically related to the Context
object. Variables are defined and accessible within a particular scope. That is, variables are
temporary, and are discarded after the scope (e.g., Procedure) in which they are defined is
exited. Note, variables declared in the User tab of the Script window are defined globally, so their
scope spans the entire program.
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. Variables are declared within a particular scope using
the Dim statement. 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, and is not automatically logged in the data file. A variable must be set as an attribute
of the Context object in order to be logged in the data file.
Variables declared at the top level of the experiment (i.e., global variables) must be declared on
the User tab in the Script window using the Dim statement. Global variables may then be
initialized within the structure of the experiment using an InLine object. Most commonly, the
initialization of global variables would be entered 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).
4.3.4.2 Naming Variables
Variable names must start with a letter, and may contain letters, digits and the underscore
character
18
. Punctuation is not allowed, although the exclamation point (!) may appear in a
position other than the first or last character. If the exclamation point is entered as the last
character, it is interpreted as a type-declaration character by E-Basic. Variable names may not
exceed 80 characters in length, and cannot be from among the list of reserved words (see the
Keywords topic in E-Basic Online Help for a listing of reserved words in the E-Basic language).
18
E-Objects named in E-Studio do not permit the use of the underscore character.