defining valid combinations

Matt Lenhart mplenhart at gmail.com
Wed Aug 27 12:51:45 UTC 2008


Hi Tim,

In general, your responses from the subject will follow the format of
XXXX{ENTER} where the X's represent the numbers 1-4. At this point,
there are two ways to determine if a valid response has been made. You
can either parse through the response and check for repeated numbers,
or you can compare the entire response to a list of valid responses.
In cases where there are a very large number of responses, I would
recommend the former. However, since you have only 24 valid responses,
I would strongly recommend the latter, since it requires far less
script, and the script it does require is far less complex.

To start, you would need to create a global array that will hold the
24 valid responses. Global variables are those that are declared on
the User tab of the Script window and retain their value throughout
the course of the experiment. They can also be accessed from any level
within the experiment. First, open the Script window via the View menu
in E-Studio, or by pressing ALT+5. Then, click the User tab. You can
declare your array as follows:

Dim arrValid(24) As String

This array is now ready for use within your experiment. Place an
InLine at the start of the SessionProc and load each valid response
into the array. To make things easier, include the {ENTER} special key
in the valid response. For example:

arrValid(1) = "1234{ENTER}"
arrValid(2) = "1324{ENTER}"
...

And so on. Then, you would place an InLine immediately following the
object that collects the subjects response to check the validity. This
would consist of using a loop to check the response against each value
in the array. If a match is found, you could set a flag variable and
exit the loop:

Dim boolMatch As Boolean
boolMatch = False

Dim nCount As Integer

For nCount = 1 To UBound(arrValid)
 If Stimulus.RESP = arrValid(nCount) Then
  boolMatch = True
  Exit For
 End If
Next

This script assumes that the object collecting the response is named
Stimulus. After this loop has ended, you can then check the value of
boolMatch to see if a match has been made, and then take the necessary
action. If the response is not valid, you can jump back to the
response object using a Label (e.g., place a Label object immediately
before the response object, and then use a Goto command in your script
to jump to the name of the Label - Goto Label1, etc).

For the second part of your question, you would need to add a bit more
script that uses the script you have already created to make
decisions. If I understand your description correctly, the correct
response would be defined as the 5th distinct response entered by the
subject, regardless of what it is. If this is the case, then you will
need to use another array to store the valid responses that have
already been made. Now, you will not only be checking the subject's
responses against the list of valid responses, but also against the
list of responses that have already been made. Both of these
conditions would need to be met in order to add it to the list of
valid responses that have been made. You can then jump back to the
response object if necessary until you have 5 valid responses. Once 5
valid responses have been made (i.e., the second array of 5 slots you
have created is full - that is, none of the slots have "" as their
value), the correct response has been entered (i.e., the value of the
5th slot in the array). You can then use this response on subsequent
trials as necessary.

If you need more information about the script necessary to do this, I
would recommend taking a look at the Array topic in the E-Basic Help
(accessed via the Help menu in E-Studio). You may also want to look at
the For...Next topic.

Please let me know if you have any quesitons.


-Matt
PST Technical Consultant
http://www.pstnet.com/

On Aug 27, 8:09 am, Victor <t1m... at yahoo.co.uk> wrote:
> Hi
>
> I am relatively new to eprime and trying to build an experiment where
> people are asked to try and find the correct combination to a lock.
> Participants are asked to input 4 numbers (1-4) and then press enter.
> Each number can only be used once in each entry, so there are 24
> possible valid responses. The correct combination will be defined as
> the 5th distinct response that is entered and subsequently rewarded
> each time it is input over approx 100 trials.
>
> What i would like to know is how to define valid responses and return
> an error message if an invalid response is input?
> I would also like to know how to record correct responses based on the
> 5th distinct response input by the participant?
>
> Any help will be greatly appreciated.
>
> Many thanks
>
> Tim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en
-~----------~----~----~----~------~----~------~--~---



More information about the Eprime mailing list