User`s guide
E-Prime User’s Guide
Chapter 4: Using E-Basic
Page 160
4.7.2 Timing
Refer to Chapter 3-Critical Timing in the User’s Guide for a detailed discussion of critical timing
issues and techniques.
4.7.3 User-Defined Data Types
E-Basic allows the user to define data types. User-defined data types are very useful for
organizing related data items of various types. A user-defined data type is declared using the
Type statement, and the data items organized by the data type are listed in the Type statement.
For example, to draw and modify a grid in which some of the cells are drawn in color, it would be
useful to keep track of an ID number for each cell, the color in which each cell is drawn, the
location of the cell, and other possible information about each cell. The script below uses the
Type statement to declare the CellInfo data type, organizing the data relevant to each cell in the
grid.
Type CellInfo 'keep track of cell info
nID As Integer
nColorState As Integer 'Is the cell a color or non-color
nColor As Long 'Specific color used to draw the cell
nRow As Integer 'Row in the grid where cell appears
nColumn As Integer 'Column in the grid
End Type
Within the Type declaration of the CellInfo data type, variables are declared to organize the
information pertaining to each cell (i.e., the cell ID, color of the cell, row, column, etc.). Once the
data type has been declared, the Dim command is used to declare a new instance of the type.
For example, the script below declares the CurrentCell variable as an instance of the CellInfo
type (i.e., a single cell in the grid).
Dim CurrentCell As CellInfo
Like assigning values to object properties, the dot operator is used to assign values to the
component variables of a user-defined type. Below, the CurrentCell variable is assigned values
for the ID number, row, column, color state, and color components.
'Define cell info
CurrentCell.nID = 12
CurrentCell.nRow = 2
CurrentCell.nColumn = 3
CurrentCell.nColorState = 1 '1 = color, 0 = white
CurrentCell.nColor = CColor("Blue")
4.7.4 Examples
4.7.4.1 Contingent Branching
Launching a specific Procedure based on the subject’s response.
This example assumes a structure in which an input object named "subject" collects a response,
and two separate List objects (List1 and List2) call separate Procedures.