Creating a loop with conditional exit (gives error)

Skip to first unread message

Elif Bastan

Nov 15, 2021, 6:38:58 AM11/15/21
to E-Prime

Hi everyone,

I am trying to create a loop with a conditional exit. The condition is having no error on a multiple-choice test. If they have an error, they have to take the test again until they give correct answers to all questions.

I have the codes for this. When I try to initialise the variables, I say trialIDx = 0 totalACC = 0 to start with the value of 0 at the beginning. The codes will be calculating the correct answers and divide them by the number of the questions. The code to exit the loop is below:

If totalACC/trialIDx < 1.0 Then
TextDisplay3.Text = "You need to work on the causal relationship again. When you feel ready, try to take the Multiple-Choice Test again."
trialIDx = 0
totalACC = 0
GoTo RedoPractice
End If
If totalACC/trialIDx = 1.0 Then
trialIDx = 0
totalACC = 0
GoTo DoTask
End If

When I try to run the experiment it gives me an error for the initialising variables part (See below for screenshot). I am wondering why.

P.S.: I am not very familiar with coding process.

I would appreciate it if you can help.

Many thanks,

Screenshot 2021-11-15 113755.png

McFarlane, David

Nov 17, 2021, 5:00:29 PM11/17/21

The error message "Variable not defined" means that, well, you tried to use a variable that has not yet been defined. E-Prime requires that all variables be defined before use, e.g.,

Dim trialIDx as Integer

See the "Dim" topic in the E-Basic Help for more details.

Also, I have a feeling that you want to define these as global variables. For information on that, please see the "Using E-Basic" chapter in the E-Basic User's Guide.

-- David McFarlane

From: <> on behalf of Elif Bastan <>
Sent: Monday, November 15, 2021 6:38 AM
To: E-Prime
Subject: Creating a loop with conditional exit (gives error)

Reply all
Reply to author
0 new messages