By DCole9 - 11/3/2014
I'm having a problem getting the following if statement to change a value correctly. I want to check the random position variable, the last trial's response, and the random demand variable to assign the location of the next stimulus. All of the if statement conditions look correct in the log file but yet it does not pass as "true" and set the values accordingly. "/ontrialbegin = [if ((values.randomposition == 1) && (values.response == "patch1") && (values.randomdemand == "lowpatch1" )) {values.lownumbery = 40%; values.highnumbery = 60%}]"
Additionally I'm having similar problem but using an if statement to insert stimulus frames. An example is- /ontrialbegin = [if ((values.randomposition == 1) && (values.response == patch2) && (values.randomdemand == "lowpatch1")) {trial.patchtrial.setstimulusframe(focus, 1); trial.patchtrial.insertstimulusframe(choose, 1); trial.patchtrial.insertstimulusframe(highnumber, 1); trial.patchtrial.insertstimulusframe(blankpatch2, 1); trial.patchtrial.insertstimulusframe(patch1, 1); }]"
|
By Dave - 11/3/2014
If you want to check if or if not any of your conditions evaluates to true, you can add
<expressions> /c1 = ((values.randomposition == 1) && (values.response == "patch1") && (values.randomdemand == "lowpatch1" )) /c2 = ((values.randomposition == 1) && (values.response == "patch2") && (values.randomdemand == "highpatch1" )) /c3 = ((values.randomposition == 2) && (values.response == "patch1") && (values.randomdemand == "lowpatch1" )) /c4 = ((values.randomposition == 2) && (values.response == "patch2") && (values.randomdemand == "highpatch1" )) </expressions>
to the script and log those expressions to the data file. You will find that you not all that can conditions are covered by your conditions. This is for example the case with
((values.randomposition == 1) && (values.response == "patch1") && (values.randomdemand == "highpatch1"))
A statement such as
/ontrialbegin = [if ((values.randomposition == 1) && (values.response == patch1) && (values.randomdemand == "lowpatch1"))
will fail to evaluate to true due to missing double-quotes.
|
By DCole9 - 11/3/2014
Thanks for the tip with the expressions Dave that helped. I'm receiving some errors with inserting the stimulus frames even though the if statements are returning true. Is there something wrong with the syntax?
"/ontrialbegin = [if ((values.randomposition == "1") && (values.response == "patch1") && (values.randomdemand == "lowpatch1")) {trial.patchtrial.setstimulusframe(focus, 1); trial.patchtrial.insertstimulusframe(choose, 1); trial.patchtrial.insertstimulusframe(lownumber, 1); trial.patchtrial.insertstimulusframe(blankpatch1, 1); trial.patchtrial.insertstimulusframe(patch2, 1)}]"
|
By Dave - 11/3/2014
What are those errors specifically?
Note that the syntax in the functions is partly incorrect: Suppose you want to set a <text> stimulus called mytext. Then that's
setstimulusframe(text.mytext, 1)
not
setstimulusframe(mytext, 1)
|
By DCole9 - 11/3/2014
D'oh! That was it! I had never needed to specify the element type before when specifying stimulus frames. I guess if you do insert or set stimulus frames then you need to but for the /stimulusframes tag you do not.
Thanks so much!
|
|