User`s guide
E-Prime User’s Guide
Chapter 4: Using E-Basic
Page 134
Rules
• Must begin with a letter.
• Numbers are acceptable but may not appear in the first character position.
• Punctuation is not permitted, with the exception of the underscore
1
character and the
exclamation point (see above paragraph for details).
• Illegal characters include: @#$%^&*(){}-+[]=><~`:;
• Spaces are not permitted.
• Maximum number of characters is 80.
• Cannot duplicate a reserved word.
• Cannot use the same name more than once within the same scope.
• The backslash character ("\") may not be used. This is an escape character within E-
Basic, which signals E-Basic to interpret the character following the backslash as a
command (e.g., "\n" would be interpreted by E-Basic as "new line").
As long as the rules above are followed, variables may be named almost anything. However, it is
highly recommended that the user follow a logical naming scheme, because this makes
programming much easier in the long run. Specifically, give variables logical names to quickly
remember their purpose. If the variable is nothing more than a counter, give it a single letter
name such as "i,” "j" and so on. If the variable’s purpose is to keep tra
birth, name the variable something like "subject_birthdate" rather than "xvariable.”
4.3.5 User Script Window vs. InLine Object
The User Script window is accessible via the Script command in the View menu. Notice the two
tabs at the bottom of the Script window, User and Full. The Full tab is useful for viewing the code
generated by E-Studio. It is not possible to edit script on the Full tab. The User tab allows
entering the user’s own high-level script.
The User Script tab in the Script window may be used to declare global variables. When
declaring variables, the variables are only accessible throughout the scope of the Procedure in
which they are declared. For example, if a variable is declared at the trial level, the variable can
only be seen, or referenced, within the scope of the trial. In order for variables to be accessible at
any level of the experiment (e.g., at both the block and trial level), the variables must be declared
within the scope of the entire experiment rather than within a specific Procedure. Script on the
User Script tab is entered into the EBS file globally.
The User Script tab in the Script window may also be used to declare functions and subroutines.
In addition to the accessibility issue described above (i.e., functions and subroutines declared on
the User Script tab may be used at any level of the experiment), there is also a syntax constraint
related to the declaration of functions and subroutines. The syntax used to declare functions and
subroutines (e.g., Sub..End Sub) will interfere with the script automatically generated by E-Prime
for the Procedure object if entered outside of the User tab. Therefore, user-defined subroutines
may not be entered using an InLine object, and must be entered on the User tab.
InLine objects are used to insert segments of user-written script within an experiment. Script
contained within InLine objects is inserted as a unit into the EBS file. The point of insertion is in
relation to the location of the InLine object within the structure of the experiment. For example, if
an InLine object is called by the trial Procedure, the script contained within the InLine will be
inserted in the EBS file at the point at which the trial Procedure is run. As alluded to above,
global variables should not be defined in an InLine, rather they should be declared in the Script
window on the User tab.