Millisecond Forums

Operator "Logical OR"

https://forums.millisecond.com/Topic17974.aspx

By Ulrike Nestler - 12/14/2015

Hello,

I am programming my own version of the stroop task in which I need correct responses, incorrect responses and ommission errors counted singularly. My problem is that I think I made a mistake how to use the operator OR and inquisit does not what I want it to. As an example:

<trial greencontrol_easy>
/ontrialbegin = [values.count_control.easy += 1]
/ontrialbegin = [values.congruency = 3]
/ pretrialpause = 250
/ stimulustimes = [0= fixation; 500=greencontrol_easy]
/ correctresponse = ("f")
/ validresponse = ("d", "f", "j")
/ timeout = 2000
/ errormessage = true(x, 400)
/ontrialend = [if (trial.greencontrol_easy.correct) {values.countcorrect_control.easy += 1; values.sumrt_control.easy += trial.greencontrol_easy.latency}]
/ontrialend = [if (trial.greencontrol_easy.response == 0 ) {values.control_oe_easy += 1; values.sumrt_control_oe_easy += trial.greencontrol_easy.latency}]
/ontrialend = [if (trial.greencontrol_easy.response == "j"|| trial.greencontrol_easy.response =="d" ) {values.incorrect_control_easy += 1; values.sumrt_control_incorrect_easy += trial.greencontrol_easy.latency}]
</trial>

The last bit [if (trial.greencontrol_easy.response == "j"|| trial.greencontrol_easy.response =="d" ) is supposed to count the wrong button presses to the incorrect trials but it doesnt work. Meaning, if the subject presses either "j" or "d", it is a wrong answer, thus it gets added to the values.incorrect_control_easy. BUt it doesnt work. Inquisit runs the entire, no question. But mistakes don't get counted.
What did I do wrong?
If you think you need the entire script, just let me know, I can send it to you as well.

Thanks.
Regards,
Ulrike Nestler
By Dave - 12/14/2015

The problem isn't the OR operator. The problem is that the response-property *does not* return the "literal" key (e.g. "d" or "k"). It returns the respective numerical keyboard scancode. Thus

if (trial.greencontrol_easy.response == "j" || trial.greencontrol_easy.response == "d")

ought to actually read

if (trial.greencontrol_easy.response == 36 || trial.greencontrol_easy.response == 32)

For details see the "Keyboard Scan Codes" topic in the documentation as well as Tools -> Keyboard Scancodes...