User`s guide

E-Prime User’s Guide
Chapter 4: Using E-Basic
Page 148
to perform the response collection again. If the required input is entered (i.e., "a"), the program
jumps to a point later in the script.
Dim answer As String
LabelB:
answer = AskBox ("Type in a letter:")
If answer = "a" Then
Goto LabelA
Else
MsgBox "That is the wrong letter, try again!"
Goto LabelB 'Ask for another letter
End If
LabelA:
MsgBox "Way to go!"
4.5.3 Examples and Exercises
To begin adding user code, it is important that the basics of programming are conceptually
understood completely. The following examples illustrate the simplicity of E-Basic code at its
best. Be sure to follow through these examples before progressing to more advanced topics. It
is recommended that each user actually implement each example, run it and verify that it works
as expected before moving on to the next section.
4.5.3.1 Example 1: Display "Hello World" on the screen
For this example to work, create a new E-Studio experiment which has only an InLine object on
the SessionProc. The InLine should contain the script provided below.
'The following statement will display a dialog box on the
'screen with the text "Hello World." By Default, an OK
'button is also displayed.
MsgBox "Hello World"
The result of the above example is:
4.5.3.2 Example 2: Setting Attributes in the Context Object
The SetAttrib method is used to create an attribute and assign it a value. Thus, the
SetAttrib method is used to place the attribute in the context so that it may be assigned,
modified, and referenced. In the example below, "c" has been defined as the Context object.
This is done internally by E-Prime, and need not be explicitly entered into the script. Thus, the
SetAttrib method is used in conjunction with the dot operator to declare TotalTrial as an
attribute of the context object ("c") and assign it a value of 10.